transport

package
v0.0.0-...-b8a7096 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package transport MIT License

# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromPeerContext

func FromPeerContext(ctx context.Context) (peer *selector.Peer, ok bool)

FromPeerContext returns the selector.Peer value stored in ctx, if any.

func NewClientContext

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

NewClientContext returns a new Context that carries Transport value.

func NewPeerClient

func NewPeerClient(ctx context.Context, peer *selector.Peer) context.Context

NewPeerClient returns a new context that carries selector.Peer value.

func NewServerContext

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

NewServerContext returns a new Context that carries Transport value.

Types

type Endpointer

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

Endpointer is a 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

func (Kind) String

func (k Kind) String() string

type Server

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

Server 服务定义

type Transporter

type Transporter interface {
	// Kind transporter
	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: /Echo.Echo/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
}

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
Package grpc MIT License
Package grpc MIT License
resolver/direct
Package direct MIT License
Package direct MIT License
resolver/discovery
Package discovery MIT License
Package discovery MIT License
Package http MIT License
Package http MIT License
binding
Package binding MIT License
Package binding MIT License
Package websocket MIT License
Package websocket MIT License

Jump to

Keyboard shortcuts

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