arf

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StreamCanceledErr = errors.New("stream canceled")

Functions

This section is empty.

Types

type CallOption

type CallOption func(*rpc.Request, *callOptions)

func WithMetadata

func WithMetadata(m rpc.Metadata) CallOption

func WithOutputMetadata

func WithOutputMetadata(m *rpc.Metadata) CallOption

func WithParams

func WithParams(params ...any) CallOption

func WithStream

func WithStream() CallOption

type Client

type Client interface {
	Close() error
	Call(ctx context.Context, serviceIdentifier, serviceMethod string, opts ...CallOption) (Context, error)
}

func Dial

func Dial(addr string, opts ...ClientOption) (Client, error)

type ClientOption

type ClientOption func(*client)

func WithTLSConfig

func WithTLSConfig(cfg *tls.Config) ClientOption

type Context

type Context interface {
	Recv() (any, error)
	Send(v any) error
	EndSend() error
	Response() *rpc.Response
	Request() *rpc.Request
	SendResponse(code status.Status, params []any, streaming bool, metadata rpc.Metadata) error
}

type IDGenerator

type IDGenerator func() (string, error)

type InOutStreamer

type InOutStreamer[I, O any] interface {
	InStreamer[I]
	OutStreamer[O]
}

func MakeInOutStream

func MakeInOutStream[I, O any](c Context) InOutStreamer[I, O]

type InStreamer

type InStreamer[T any] interface {
	Recv() (T, error)
}

func MakeInStream

func MakeInStream[I any](c Context) InStreamer[I]

type Interceptor

type Interceptor func(ctx context.Context, req Context, next Interceptor) error

type OutStreamer

type OutStreamer[T any] interface {
	Send(T) error
	Close() error
}

func MakeOutStream

func MakeOutStream[O any](c Context) OutStreamer[O]

type Server

type Server interface {
	RegisterService(service Service) error
	MustRegisterService(service Service)
	Serve() error
	Shutdown() error
	RegisterInterceptor(interceptor ...Interceptor)
}

func NewServer

func NewServer(l net.Listener, opts ServerOptions) (Server, error)

func NewServerListen

func NewServerListen(addr string, opts ServerOptions) (Server, error)

type ServerOptions

type ServerOptions struct {
	MaxConcurrentStreams uint32 /* TODO */
	Logger               stdlog.Logger
	IDGenerator          IDGenerator
}

type Service

type Service interface {
	ServiceResponder
	ArfServiceID() string
	RespondsTo(name string) bool
}

type ServiceAdapter

type ServiceAdapter struct {
	Methods   map[string]ServiceExecutor
	ServiceID string
}

func (ServiceAdapter) ArfServiceID

func (s ServiceAdapter) ArfServiceID() string

func (ServiceAdapter) InvokeMethod

func (s ServiceAdapter) InvokeMethod(name string, ctx context.Context, request Context) error

func (ServiceAdapter) RespondsTo

func (s ServiceAdapter) RespondsTo(name string) bool

type ServiceExecutor

type ServiceExecutor func(context.Context, Context) error

type ServiceResponder

type ServiceResponder interface {
	InvokeMethod(name string, ctx context.Context, request Context) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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