transport

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MIT Imports: 2 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

NewClientContext returns a new Context that carries value.

func NewServerContext

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

NewServerContext returns a new Context that carries value.

Types

type Endpointer

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

Endpointer is registry endpoint.

type Header interface {
	Get(key string) string
	Set(key string, value string)
	Add(key string, 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 type of Transport

const (
	KindGRPC Kind = "grpc"
	KindHTTP Kind = "http"
	KindTCP  Kind = "tcp"
)

Defines a set of transport kind

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
	// tcp
	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 // grpc method or http path  , tcp 为空
	// RequestHeader return transport request header
	// http: http.Header
	// grpc: metadata.MD
	RequestHeader() Header //tcp没有
	// ReplyHeader return transport reply/response header
	// only valid for server transport
	// http: http.Header
	// grpc: metadata.MD
	ReplyHeader() Header //tcp没有
}

Transporter is transport context value interface.

func FromClientContext

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

FromClientContext returns the Transport value stored in ctx, if any.

func FromServerContext

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

FromServerContext returns the Transport value stored in ctx, if any.

Directories

Path Synopsis
tcp
iface
@Title iclient.go @Description Provides all interface declarations for the Client abstraction layer.
@Title iclient.go @Description Provides all interface declarations for the Client abstraction layer.

Jump to

Keyboard shortcuts

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