arpc

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Context added in v0.3.2

func Context(ctx *arpc.Context) scene.Context

func NewARpcContainer

func NewARpcContainer(
	addr string,
	apps []ARpcApp,
	opts ...ServerOption) scene.Scene

NewARpcContainer create a arpc container

Types

type ARpcApp

type ARpcApp interface {
	scene.Application
	RegisterService(handler arpc.Handler) error
}

type Client

type Client interface {
	scene.Named
	Logger() logger.ILogger
	Client() *arpc.Client
	Call(method string, req interface{}, rsp interface{}, timeout time.Duration, args ...interface{}) error
	AddConnectedHandler(func(c *arpc.Client))
}

func NewClient

func NewClient(network string, addr string, options ...ClientOption) Client

type ClientFactory

type ClientFactory struct {
	scene.ModuleFactory
	Network string
	Addr    string
	Options []ClientOption
}

func (ClientFactory) Init

func (c ClientFactory) Init() scene.LensInit

type ClientOption

type ClientOption func(server Client) error

ClientOption is initialization option for arpc Client

func WithAesEncryption

func WithAesEncryption(key []byte) ClientOption

WithAesEncryption enables automatic AES encryption for all messages on the client after a successful handshake.

func WithNexusGateway added in v0.3.2

func WithNexusGateway(apps ...ARpcApp) ClientOption

func WithPassword

func WithPassword(password string) ClientOption

type DiscoverResponse added in v0.3.2

type DiscoverResponse struct {
	Methods map[string][]ServiceInstance `json:"methods"`
}

func DiscoverViaNexus added in v0.3.2

func DiscoverViaNexus(ctx context.Context, nexus Client, timeout time.Duration) (DiscoverResponse, error)

DiscoverViaNexus queries services currently attached to the gateway.

type NexusClientFactory added in v0.3.2

type NexusClientFactory struct {
	scene.ModuleFactory
	Network string
	Addr    string
	Options []ClientOption
	UseApps []scene.AppInit[ARpcApp]
}

func (NexusClientFactory) Init added in v0.3.2

type NexusGateway added in v0.3.2

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

func EnableNexus added in v0.3.2

func EnableNexus(server *arpc.Server, defaultTimeout time.Duration, log logger.ILogger) *NexusGateway

EnableNexus wires a server to behave as a nexus gateway. It registers internal handlers for registration/proxy/discovery.

type ProxyRequest added in v0.3.2

type ProxyRequest struct {
	Method   string          `json:"method"`
	Payload  json.RawMessage `json:"payload"`
	TimeoutM int64           `json:"timeout_ms,omitempty"`
}

type ProxyResponse added in v0.3.2

type ProxyResponse struct {
	Payload json.RawMessage `json:"payload,omitempty"`
	Error   string          `json:"error,omitempty"`
}

type RegisterMethodRequest added in v0.3.2

type RegisterMethodRequest struct {
	Method     string            `json:"method"`
	InstanceID string            `json:"instance_id"`
	Metadata   map[string]string `json:"metadata,omitempty"`
}

type RegisterServiceResponse added in v0.3.2

type RegisterServiceResponse struct {
	InstanceID string `json:"instance_id"`
}

func RegisterMethodViaNexus added in v0.3.2

func RegisterMethodViaNexus(ctx context.Context, nexus Client, req RegisterMethodRequest, timeout time.Duration) (RegisterServiceResponse, error)

RegisterMethodViaNexus registers the current service instance to a nexus gateway. If ctx is nil, context.Background will be used.

type ServerOption added in v0.3.2

type ServerOption func(server *arpc.Server) error

func UseAesEncryption

func UseAesEncryption(key []byte) ServerOption

UseAesEncryption enables automatic AES decryption for all messages after a successful handshake.

func UseNexusGateway added in v0.3.2

func UseNexusGateway(timeout time.Duration, holders ...**NexusGateway) ServerOption

UseNexusGateway turns the current server into a nexus gateway for proxy-based discovery mode. If holder pointers are provided, the created gateway will be written back for later use.

func UsePassword

func UsePassword(password string) ServerOption

func UseRecover

func UseRecover() ServerOption

type ServiceInstance added in v0.3.2

type ServiceInstance struct {
	InstanceID string            `json:"instance_id"`
	Metadata   map[string]string `json:"metadata,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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