Documentation
¶
Index ¶
- func Context(ctx *arpc.Context) scene.Context
- func NewARpcContainer(addr string, apps []ARpcApp, opts ...ServerOption) scene.Scene
- type ARpcApp
- type Client
- type ClientFactory
- type ClientOption
- type ClientProvider
- type DiscoverResponse
- type NexusClientFactory
- type NexusGateway
- type ProxyRequest
- type ProxyResponse
- type RegisterMethodRequest
- type RegisterServiceResponse
- type ServerOption
- type ServiceInstance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ClientFactory ¶
type ClientFactory struct {
scene.ModuleFactory
Network string
Addr string
Options []ClientOption
}
func (ClientFactory) Init ¶
func (c ClientFactory) Init() scene.LensInit
type ClientOption ¶
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 ClientProvider ¶
type ClientProvider scene.IModuleDependencyProvider[Client]
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
func (c NexusClientFactory) Init() scene.LensInit
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 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
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