Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from johanbrandhorst/bump-grpc-gateway
Browse files Browse the repository at this point in the history
Bump grpc-gateway version
  • Loading branch information
benesch authored Dec 23, 2017
2 parents 1086d1b + fc3aa43 commit 82effb8
Show file tree
Hide file tree
Showing 46 changed files with 2,188 additions and 317 deletions.
6 changes: 3 additions & 3 deletions github.com/andy-kimball/arenaskl/arena.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (a *Arena) Reset() {
atomic.StoreUint32(&a.n, 1)
}

func (a *Arena) Alloc(size uint16, align Align) (uint32, error) {
func (a *Arena) Alloc(size uint32, align Align) (uint32, error) {
// Pad the allocation with enough bytes to ensure the requested alignment.
padded := uint32(size) + uint32(align)

Expand All @@ -76,12 +76,12 @@ func (a *Arena) Alloc(size uint16, align Align) (uint32, error) {
return offset, nil
}

func (a *Arena) GetBytes(offset uint32, size uint16) []byte {
func (a *Arena) GetBytes(offset uint32, size uint32) []byte {
if offset == 0 {
return nil
}

return a.buf[offset : offset+uint32(size)]
return a.buf[offset : offset+size]
}

func (a *Arena) GetPointer(offset uint32) unsafe.Pointer {
Expand Down
2 changes: 1 addition & 1 deletion github.com/andy-kimball/arenaskl/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (it *Iterator) Key() []byte {
// Value returns the value at the current position.
func (it *Iterator) Value() []byte {
valOffset, valSize := decodeValue(it.value)
return it.arena.GetBytes(valOffset, valSize)
return it.arena.GetBytes(valOffset, uint32(valSize))
}

// Meta returns the metadata at the current position.
Expand Down
11 changes: 3 additions & 8 deletions github.com/andy-kimball/arenaskl/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ func (l *links) init(prevOffset, nextOffset uint32) {
type node struct {
// Immutable fields, so no need to lock to access key.
keyOffset uint32
keySize uint16

// Height of this node's tower.
height uint16
keySize uint32

// Multiple parts of the value are encoded as a single uint64 so that it
// can be atomically loaded and stored:
Expand Down Expand Up @@ -65,19 +62,17 @@ func newNode(arena *Arena, height uint32) (nd *node, err error) {
// is less than maxHeight.
unusedSize := (maxHeight - int(height)) * linksSize

nodeOffset, err := arena.Alloc(uint16(MaxNodeSize-unusedSize), Align8)
nodeOffset, err := arena.Alloc(uint32(MaxNodeSize-unusedSize), Align8)
if err != nil {
return
}

nd = (*node)(arena.GetPointer(nodeOffset))
nd.height = uint16(height)

return
}

func (n *node) getKey(arena *Arena) []byte {
return arena.GetBytes(n.keyOffset, uint16(n.keySize))
return arena.GetBytes(n.keyOffset, n.keySize)
}

func (n *node) nextOffset(h int) uint32 {
Expand Down
11 changes: 5 additions & 6 deletions github.com/andy-kimball/arenaskl/skl.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ func (s *Skiplist) randomHeight() uint32 {
return h
}

func (s *Skiplist) allocKey(key []byte) (keyOffset uint32, keySize uint16, err error) {
if len(key) > math.MaxUint16 {
func (s *Skiplist) allocKey(key []byte) (keyOffset uint32, keySize uint32, err error) {
if len(key) > math.MaxUint32 {
panic("key is too large")
}

keySize = uint16(len(key))
keySize = uint32(len(key))
keyOffset, err = s.arena.Alloc(keySize, Align1)
if err == nil {
copy(s.arena.GetBytes(keyOffset, keySize), key)
Expand All @@ -191,13 +191,12 @@ func (s *Skiplist) allocVal(val []byte, meta uint16) (uint64, error) {
}

valSize := uint16(len(val))

valOffset, err := s.arena.Alloc(valSize, Align1)
valOffset, err := s.arena.Alloc(uint32(valSize), Align1)
if err != nil {
return 0, err
}

copy(s.arena.GetBytes(valOffset, valSize), val)
copy(s.arena.GetBytes(valOffset, uint32(valSize)), val)
return encodeValue(valOffset, valSize, meta), nil
}

Expand Down
1 change: 1 addition & 0 deletions github.com/grpc-ecosystem/grpc-gateway/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
_output/
.idea
2 changes: 1 addition & 1 deletion github.com/grpc-ecosystem/grpc-gateway/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ env:
- "PATH=$PATH:$HOME/local/bin"
matrix:
- GATEWAY_PLUGIN_FLAGS=
- GATEWAY_PLUGIN_FLAGS=request_context=true
- GATEWAY_PLUGIN_FLAGS=request_context=false
11 changes: 9 additions & 2 deletions github.com/grpc-ecosystem/grpc-gateway/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ OUTPUT_DIR=_output
RUNTIME_PROTO=runtime/internal/stream_chunk.proto
RUNTIME_GO=$(RUNTIME_PROTO:.proto=.pb.go)

OPENAPIV2_PROTO=protoc-gen-swagger/options/openapiv2.proto protoc-gen-swagger/options/annotations.proto
OPENAPIV2_GO=$(OPENAPIV2_PROTO:.proto=.pb.go)

PKGMAP=Mgoogle/protobuf/descriptor.proto=$(GO_PLUGIN_PKG)/descriptor,Mexamples/sub/message.proto=$(PKG)/examples/sub
ADDITIONAL_FLAGS=
ifneq "$(GATEWAY_PLUGIN_FLAGS)" ""
Expand Down Expand Up @@ -83,17 +86,20 @@ generate: $(RUNTIME_GO)

.SUFFIXES: .go .proto

$(GO_PLUGIN):
$(GO_PLUGIN):
go get $(GO_PLUGIN_PKG)
go build -o $@ $(GO_PLUGIN_PKG)

$(RUNTIME_GO): $(RUNTIME_PROTO) $(GO_PLUGIN)
protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP):. $(RUNTIME_PROTO)

$(OPENAPIV2_GO): $(OPENAPIV2_PROTO) $(GO_PLUGIN)
protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP):$(GOPATH)/src $(OPENAPIV2_PROTO)

$(GATEWAY_PLUGIN): $(RUNTIME_GO) $(GATEWAY_PLUGIN_SRC)
go build -o $@ $(GATEWAY_PLUGIN_PKG)

$(SWAGGER_PLUGIN): $(SWAGGER_PLUGIN_SRC)
$(SWAGGER_PLUGIN): $(SWAGGER_PLUGIN_SRC) $(OPENAPIV2_GO)
go build -o $@ $(SWAGGER_PLUGIN_PKG)

$(EXAMPLE_SVCSRCS): $(GO_PLUGIN) $(EXAMPLES)
Expand Down Expand Up @@ -143,5 +149,6 @@ realclean: distclean
rm -f $(GO_PLUGIN)
rm -f $(SWAGGER_PLUGIN)
rm -f $(EXAMPLE_CLIENT_SRCS)
rm -f $(OPENAPIV2_GO)

.PHONY: generate examples test lint clean distclean realclean
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* examples/examplepb/a_bit_of_everything.proto
* A Bit of Everything
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: version not set
*
* OpenAPI spec version: 1.0
* Contact: none@example.com
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/

Expand Down
Loading

0 comments on commit 82effb8

Please sign in to comment.