transport

package
v0.0.0-...-9eed78a Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 8 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 EndpointRegister

type EndpointRegister interface {
	Endpoint() (*url.URL, error)
}

EndpointRegister is registry endpoint.

type Header interface {
	Get(key string) string
	Set(key, value string)
	Add(key, value string)
	Keys() []string
	Values(key string) []string
}

Header is the storage medium used by a Header.

type Kind

type Kind string // Kind defines the transport type
const (
	KindGRPC Kind = "grpc"
	KindHTTP Kind = "http"
)

func (Kind) String

func (k Kind) String() string

type Server

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

Server is transport server.

type Transporter

type Transporter interface {
	// Kind transporter
	// grpc
	// http
	Kind() Kind
	// Endpoint returns server/client endpoint
	Endpoint() string
	// Operation Service full method selector generated by protobuf, like /hello.Greeter/SayHello
	Operation() string
	// RequestHeader returns the transport request header
	// grpc: [metadata.MD]
	// http: [http.Header]
	RequestHeader() Header
	// ReplyHeader returns the transport reply/response header
	// grpc: [metadata.MD]
	// http: [http.Header]
	ReplyHeader() Header
}

Transporter is transport context value interface.

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

Jump to

Keyboard shortcuts

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