transport

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientContext

func NewClientContext(ctx context.Context, tr Transporter) context.Context

func NewServerContext

func NewServerContext(ctx context.Context, tr Transporter) context.Context

Types

type Endpointer

type Endpointer interface {
	Endpoint() (*url.URL, error)
}
type Header interface {
	Get(key string) string
	Set(key, value string)
	Keys() []string
}

type Kind

type Kind string
const (
	KindGRPC Kind = "grpc"
	KindHTTP Kind = "http"
)

func (Kind) String

func (k Kind) String() string

type Server

type Server interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
}

type Transporter

type Transporter interface {
	// Kind http, grpc
	Kind() Kind
	// Endpoint return server or client endpoint
	// Server Transport: grpc://127.0.0.1:9000
	// Client Transport: discovery:///provider-demo
	Endpoint() string
	// Operation Service full method selector generated by protobuf
	// example: /helloworld.Greeter/SayHello
	Operation() string
	// RequestHeader return transport request header
	// http: http.Header
	// grpc: metadata.MD
	RequestHeader() Header
	// ReplyHeader return transport reply/response header
	// only valid for server transport
	// http: http.Header
	// grpc: metadata.MD
	ReplyHeader() Header
}

func FromClientContext

func FromClientContext(ctx context.Context) (tr Transporter, ok bool)

func FromServerContext

func FromServerContext(ctx context.Context) (tr Transporter, ok bool)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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