transport

package
v0.0.0-...-315a808 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package transport is an interface for synchronous connection based communication

Index

Constants

View Source
const (
	// Topic  call/stream
	Topic = "Micro-Topic"
	// Service  call/stream
	Service = "Micro-Service"
	// Error header contains an error message.
	Error = "Micro-Error"
	// Endpoint header.
	Endpoint = "Micro-Endpoint"
	// Method header.
	Method = "Micro-Method"
	// ID header.
	ID = "Micro-ID"
	// Prefix used to prefix headers.
	Prefix = "Micro-"
	// Namespace header.
	Namespace = "Micro-Namespace"
	// Protocol header.
	Protocol = "Micro-Protocol"
	// Target header.
	Target = "Micro-Target"
	// SpanID header.
	SpanID = "Micro-Span-ID"
	// TraceIDKey header.
	TraceIDKey = "Micro-Trace-ID"
	// Stream header.
	Stream = "Micro-Stream"
	Query  = "Micro-Query" // url query

)
View Source
const (
	DefaultDialTimeout = time.Second * 5
)

Variables

This section is empty.

Functions

func ContextDelete

func ContextDelete(ctx context.Context, k string) context.Context

ContextDelete key from metadata.

func ContextGet

func ContextGet(ctx context.Context, key string) (string, bool)

ContextGet returns a single value from metadata in the context.

func ContextSet

func ContextSet(ctx context.Context, k, v string) context.Context

ContextSet add key with val to metadata.

func CopyFromContext

func CopyFromContext(ctx context.Context) map[string]string

func MergeContext

func MergeContext(ctx context.Context, patchMd Metadata, overwrite bool) context.Context

MergeContext merges metadata to existing metadata, overwriting if specified.

func NewContext

func NewContext(ctx context.Context, md Metadata) context.Context

NewContext creates a new context with the given metadata.

Types

type Client

type Client interface {
	Socket
}

type Conn

type Conn struct {
	Client
	// contains filtered or unexported fields
}

func (*Conn) Close

func (p *Conn) Close() error

func (*Conn) Created

func (p *Conn) Created() time.Time

func (*Conn) Id

func (p *Conn) Id() string

type Message

type Message struct {
	Header map[string]string
	Body   []byte
}

Message is a broker message.

type Metadata

type Metadata map[string]string

Metadata is our way of representing request headers internally. They're used at the RPC level and translate back and forth from Transport headers.

func FromContext

func FromContext(ctx context.Context) (Metadata, bool)

FromContext returns metadata from the given context.

func MetadataCopy

func MetadataCopy(md Metadata) Metadata

MetadataCopy makes a copy of the metadata.

func (Metadata) Delete

func (md Metadata) Delete(key string)

func (Metadata) Get

func (md Metadata) Get(key string) (string, bool)

func (Metadata) Set

func (md Metadata) Set(key, val string)

type Pool

type Pool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewPool

func NewPool(size int, ttl time.Duration, transport Transport) *Pool

func (*Pool) Close

func (p *Pool) Close() error

func (*Pool) Get

func (p *Pool) Get(addr string, timeout time.Duration) (*Conn, error)

func (*Pool) Release

func (p *Pool) Release(conn *Conn, err error) error

type Socket

type Socket interface {
	Recv(*Message) error
	Send(*Message) error
	Close() error
	Local() string
	Remote() string
}

type Transport

type Transport interface {
	Dial(addr string, timeout time.Duration) (Client, error)
	String() string
}

Transport is an interface which is used for communication between services. It uses connection based socket send/recv semantics and has various implementations; http, grpc, quic.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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