rpc_interface

package
v0.0.0-20240423 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallOption

type CallOption = option.ApplyOption

type CallRequest

type CallRequest = any

type CallResponse

type CallResponse = any

type CallStreamOption

type CallStreamOption = option.ApplyOption

type Caller

type Caller interface {
	Call(ctx context.Context, method string, req CallRequest, res CallResponse, opts ...CallOption) error
	CallStream(ctx context.Context, method string, opts ...CallStreamOption) (Stream, error)
}

type HandleFunc

type HandleFunc = func(context.Context, HandleRequest) (HandleResponse, error)

type HandleOption

type HandleOption = option.ApplyOption

type HandleRequest

type HandleRequest = []byte

type HandleResponse

type HandleResponse = []byte

type HandleStreamFunc

type HandleStreamFunc = func(context.Context, Stream) error

type HandleStreamOption

type HandleStreamOption = option.ApplyOption

type Handler

type Handler interface {
	Handle(method string, fn HandleFunc, opts ...HandleOption)
	HandleStream(method string, fn HandleStreamFunc, opts ...HandleStreamOption)
	Do(ctx context.Context, method string, req HandleRequest) (HandleResponse, error)
	DoStream(ctx context.Context, method string, stm Stream) error
}

type Message

type Message interface {
	Unmarshal(v any) error
	ToBytes() ([]byte, error)
}

type MessageMarshaler

type MessageMarshaler interface {
	Marshal(v any) (Message, error)
}

type MessageParser

type MessageParser interface {
	FromBytes([]byte) (Message, error)
}

type NewCallerOption

type NewCallerOption = option.ApplyOption

type NewHandlerOption

type NewHandlerOption = option.ApplyOption

type NewServerOption

type NewServerOption = option.ApplyOption

type Server

type Server interface {
	Serve(context.Context) <-chan error
	Terminate(context.Context) error
	Wait(context.Context) <-chan error
}

type Stream

type Stream interface {
	Marshaler() MessageMarshaler
	RecvMessage() (Message, error)
	SendMessage(Message) error
	io.Closer
}

Jump to

Keyboard shortcuts

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