-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drpcmetadata: encode and decode metadata (#2)
- Loading branch information
Yingrong Zhao
authored
Mar 20, 2020
1 parent
d44aecc
commit 3311ebb
Showing
14 changed files
with
400 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# package drpcmetadata | ||
|
||
`import "storj.io/drpc/drpcmetadata"` | ||
|
||
Package drpcmetadata define the structure of the metadata supported by drpc | ||
library. | ||
|
||
## Usage | ||
|
||
#### func Add | ||
|
||
```go | ||
func Add(ctx context.Context, key, value string) context.Context | ||
``` | ||
Add associates a key/value pair on the context. | ||
|
||
#### func AddPairs | ||
|
||
```go | ||
func AddPairs(ctx context.Context, md map[string]string) context.Context | ||
``` | ||
AddPairs attaches metadata onto a context and return the context. | ||
|
||
#### func Decode | ||
|
||
```go | ||
func Decode(data []byte) (*invoke.InvokeMetadata, error) | ||
``` | ||
Decode translate byte form of metadata into metadata struct defined by protobuf. | ||
|
||
#### func Encode | ||
|
||
```go | ||
func Encode(buffer []byte) ([]byte, error) | ||
``` | ||
Encode generates byte form of the metadata and appends it onto the passed in | ||
buffer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (C) 2019 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
// Package drpcmetadata define the structure of the metadata supported by drpc library. | ||
package drpcmetadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# package invoke | ||
|
||
`import "storj.io/drpc/drpcmetadata/invoke"` | ||
|
||
Package invoke defines the proto messages exposed by drpc for sending metadata | ||
across the wire. | ||
|
||
## Usage | ||
|
||
#### type InvokeMetadata | ||
|
||
```go | ||
type InvokeMetadata struct { | ||
Data map[string]string `protobuf:"bytes,2,rep,name=data,proto3" json:"data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||
XXX_NoUnkeyedLiteral struct{} `json:"-"` | ||
XXX_unrecognized []byte `json:"-"` | ||
XXX_sizecache int32 `json:"-"` | ||
} | ||
``` | ||
|
||
|
||
#### func (*InvokeMetadata) Descriptor | ||
|
||
```go | ||
func (*InvokeMetadata) Descriptor() ([]byte, []int) | ||
``` | ||
|
||
#### func (*InvokeMetadata) GetData | ||
|
||
```go | ||
func (m *InvokeMetadata) GetData() map[string]string | ||
``` | ||
|
||
#### func (*InvokeMetadata) ProtoMessage | ||
|
||
```go | ||
func (*InvokeMetadata) ProtoMessage() | ||
``` | ||
|
||
#### func (*InvokeMetadata) Reset | ||
|
||
```go | ||
func (m *InvokeMetadata) Reset() | ||
``` | ||
|
||
#### func (*InvokeMetadata) String | ||
|
||
```go | ||
func (m *InvokeMetadata) String() string | ||
``` | ||
|
||
#### func (*InvokeMetadata) XXX_DiscardUnknown | ||
|
||
```go | ||
func (m *InvokeMetadata) XXX_DiscardUnknown() | ||
``` | ||
|
||
#### func (*InvokeMetadata) XXX_Marshal | ||
|
||
```go | ||
func (m *InvokeMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) | ||
``` | ||
|
||
#### func (*InvokeMetadata) XXX_Merge | ||
|
||
```go | ||
func (m *InvokeMetadata) XXX_Merge(src proto.Message) | ||
``` | ||
|
||
#### func (*InvokeMetadata) XXX_Size | ||
|
||
```go | ||
func (m *InvokeMetadata) XXX_Size() int | ||
``` | ||
|
||
#### func (*InvokeMetadata) XXX_Unmarshal | ||
|
||
```go | ||
func (m *InvokeMetadata) XXX_Unmarshal(b []byte) error | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (C) 2019 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
// Package invoke defines the proto messages exposed by drpc for | ||
// sending metadata across the wire. | ||
package invoke | ||
|
||
//go:generate bash -c "go install storj.io/drpc/cmd/protoc-gen-drpc && protoc --drpc_out=plugins=drpc:. metadata.proto" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (C) 2019 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
syntax = "proto3"; | ||
option go_package = "invoke"; | ||
|
||
package metadata; | ||
|
||
message Metadata { | ||
map<string, string> data = 1; | ||
} |
Oops, something went wrong.