metadata

package
v0.0.0-...-1a196e1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2017 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMap

func NewMap(metadata map[string]string) md.MD

NewMap 會接收一個基於 map 結構的中繼資料然後轉換成 gRPC 的中繼資料。

Types

type Info

type Info struct {
	ServiceName string
}

Info 是用來建立中繼資料的資訊建構體。

type MD

type MD map[string][]string

MD 是中繼資料的型態。

func FromContext

func FromContext(ctx context.Context) (metadata MD, ok bool)

FromContext 會解析傳入的 Context 並取得、回傳其中的中繼資料。

type Metadata

type Metadata struct {
	// MD 存放了原生的 gRPC metadata。
	MD *MD
}

Metadata 呈現了一個基本的中繼資料。

func New

func New(info Info) *Metadata

New 會接收一個資訊建構體用來初始化、回傳一個新的中繼資料。

func (*Metadata) Context

func (m *Metadata) Context() context.Context

Context 會將目前的中繼資料轉換成 context.Context 以便利於傳入其他函式中。

func (*Metadata) ContextMap

func (m *Metadata) ContextMap(metadata map[string]string) context.Context

ContextMap 會接收 map 型態的中繼資料並與目前的中繼資料合併, 然後將其轉換成 context.Context 以便利於傳入其他函式中。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL