net

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapRPCErr

func WrapRPCErr(err error) error

Types

type AtomicBroker

type AtomicBroker struct {
	// contains filtered or unexported fields
}

An AtomicBroker implements Broker and is backed by a swappable *plugin.GRPCBroker.

func (*AtomicBroker) Accept

func (a *AtomicBroker) Accept(id uint32) (net.Listener, error)

func (*AtomicBroker) DialWithOptions

func (a *AtomicBroker) DialWithOptions(id uint32, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)

func (*AtomicBroker) Load

func (a *AtomicBroker) Load() Broker

func (*AtomicBroker) NextId

func (a *AtomicBroker) NextId() uint32

func (*AtomicBroker) Store

func (a *AtomicBroker) Store(b Broker)

type AtomicClient

type AtomicClient struct {
	// contains filtered or unexported fields
}

An AtomicClient implements grpc.ClientConnInterface and is backed by a swappable *grpc.ClientConn.

func (*AtomicClient) Invoke

func (a *AtomicClient) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...grpc.CallOption) error

func (*AtomicClient) NewStream

func (a *AtomicClient) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)

func (*AtomicClient) Store

func (a *AtomicClient) Store(cc *grpc.ClientConn)

type Broker

type Broker interface {
	Accept(id uint32) (net.Listener, error)
	DialWithOptions(id uint32, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)
	NextId() uint32
}

Broker is a subset of the methods exported by *plugin.GRPCBroker.

type BrokerConfig

type BrokerConfig struct {
	StopCh <-chan struct{}
	Logger logger.Logger

	GRPCOpts // optional
}

BrokerConfig holds Broker configuration fields.

type BrokerExt

type BrokerExt struct {
	Broker Broker
	BrokerConfig
}

BrokerExt extends a Broker with various helper methods.

func (*BrokerExt) CloseAll

func (b *BrokerExt) CloseAll(deps ...Resource)

func (*BrokerExt) Dial

func (b *BrokerExt) Dial(id uint32) (conn *grpc.ClientConn, err error)

func (*BrokerExt) NewClientConn

func (b *BrokerExt) NewClientConn(name string, newClient newClientFn) *clientConn

NewClientConn return a new *clientConn backed by this *BrokerExt.

func (*BrokerExt) Serve

func (b *BrokerExt) Serve(name string, server *grpc.Server, deps ...Resource) (uint32, Resource, error)

func (*BrokerExt) ServeNew

func (b *BrokerExt) ServeNew(name string, register func(*grpc.Server), deps ...Resource) (uint32, Resource, error)

func (*BrokerExt) StopCtx

func (b *BrokerExt) StopCtx() (context.Context, context.CancelFunc)

func (*BrokerExt) WithName

func (b *BrokerExt) WithName(name string) *BrokerExt

WithName returns a new *BrokerExt with Name added to the logger.

type ErrConnAccept

type ErrConnAccept struct {
	ID   uint32
	Name string
	Err  error
}

func (ErrConnAccept) Error

func (e ErrConnAccept) Error() string

func (ErrConnAccept) Unwrap

func (e ErrConnAccept) Unwrap() error

type ErrConnDial

type ErrConnDial struct {
	ID   uint32
	Name string
	Err  error
}

func (ErrConnDial) Error

func (e ErrConnDial) Error() string

func (ErrConnDial) Unwrap

func (e ErrConnDial) Unwrap() error

type GRPCOpts

type GRPCOpts struct {
	// Optionally include additional options when dialing a client.
	// Normally aligned with [plugin.ClientConfig.GRPCDialOptions].
	DialOpts []grpc.DialOption
	// Optionally override the default *grpc.Server constructor.
	// Normally aligned with [plugin.ServeConfig.GRPCServer].
	NewServer func([]grpc.ServerOption) *grpc.Server
}

GRPCOpts has GRPC client and server options.

type Resource

type Resource struct {
	io.Closer
	Name string
}

type Resources

type Resources []Resource

func (*Resources) Add

func (rs *Resources) Add(r Resource)

func (*Resources) Close

func (rs *Resources) Close(c io.Closer, name string)

func (*Resources) Stop

func (rs *Resources) Stop(s interface{ Stop() }, name string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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