Documentation
¶
Index ¶
- Constants
- type Config
- func (x *Config) BindAddr() string
- func (x *Config) BindPort() int
- func (x *Config) IdleTimeout() time.Duration
- func (x *Config) MaxFrameSize() uint32
- func (x *Config) NodeName() string
- func (x *Config) ReadIdleTimeout() time.Duration
- func (x *Config) Sanitize() error
- func (x *Config) Validate() error
- func (x *Config) WriteTimeout() time.Duration
- type Option
- type OptionFunc
- type Remoting
- type RemotingOption
- type SpawnRequest
Constants ¶
const DefaultMaxReadFrameSize = 16 * size.MB
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config defines the remote config
func (*Config) IdleTimeout ¶
IdleTimeout specifies how long until idle clients should be closed with a GOAWAY frame. PING frames are not considered activity for the purposes of IdleTimeout. If zero or negative, there is no timeout.
func (*Config) MaxFrameSize ¶
MaxFrameSize specifies the largest frame this server is willing to read. A valid value is between 16k and 16M, inclusive. If zero or otherwise invalid, an error will be thrown.
func (*Config) ReadIdleTimeout ¶
ReadIdleTimeout is the timeout after which a health check using a ping frame will be carried out if no frame is received on the connection. If zero, no health check is performed.
func (*Config) WriteTimeout ¶
WriteTimeout is the timeout after which a connection will be closed if no data can be written to it. The timeout begins when data is available to write, and is extended whenever any bytes are written. If zero or negative, there is no timeout.
type Option ¶
type Option interface {
// Apply sets the Option value of a config.
Apply(*Config)
}
Option is the interface that applies a configuration option.
func WithMaxFrameSize ¶
WithMaxFrameSize specifies the largest frame this server is willing to read. A valid value is between 16k and 16M, inclusive. If zero or otherwise invalid, an error will be thrown.
func WithNodeName ¶
WithNodeName allows for overriding the node name in cases where IP resolution leads to undesired results.
func WithReadIdleTimeout ¶
WithReadIdleTimeout sets the read timeout ReadIdleTimeout is the timeout after which a health check using a ping frame will be carried out if no frame is received on the connection. If zero, no health check is performed.
func WithWriteTimeout ¶
WithWriteTimeout sets the write timeout
type OptionFunc ¶
type OptionFunc func(config *Config)
OptionFunc implements the Option interface.
func (OptionFunc) Apply ¶
func (f OptionFunc) Apply(c *Config)
type Remoting ¶
type Remoting interface {
RemoteTell(ctx context.Context, from, to *address.Address, message proto.Message) error
RemoteAsk(ctx context.Context, from, to *address.Address, message proto.Message, timeout time.Duration) (response *anypb.Any, err error)
RemoteLookup(ctx context.Context, host string, port int, name string) (addr *address.Address, err error)
RemoteBatchTell(ctx context.Context, from, to *address.Address, messages []proto.Message) error
RemoteBatchAsk(ctx context.Context, from, to *address.Address, messages []proto.Message, timeout time.Duration) (responses []*anypb.Any, err error)
RemoteSpawn(ctx context.Context, host string, port int, spawnRequest *SpawnRequest) error
RemoteReSpawn(ctx context.Context, host string, port int, name string) error
RemoteStop(ctx context.Context, host string, port int, name string) error
RemoteReinstate(ctx context.Context, host string, port int, name string) error
HTTPClient() *nethttp.Client
MaxReadFrameSize() int
Close()
RemotingServiceClient(host string, port int) internalpbconnect.RemotingServiceClient
}
func NewRemoting ¶
func NewRemoting(opts ...RemotingOption) Remoting
NewRemoting creates an instance Remoting with an insecure connection. To use a secure connection one need to call the WithTLS method of the remoting instance to set the certificates of the secure connection This requires Remoting is enabled on the connected actor system Make sure to call Close to free up resources otherwise you may be leaking socket connections
One can also override the remoting option when calling any of the method for custom one.
type RemotingOption ¶
type RemotingOption func(*remoting)
RemotingOption sets the remoting option
func WithRemotingMaxReadFameSize ¶
func WithRemotingMaxReadFameSize(size int) RemotingOption
WithRemotingMaxReadFameSize sets both the maximum framesize to send and receive
func WithRemotingTLS ¶
func WithRemotingTLS(tlsConfig *tls.Config) RemotingOption
WithRemotingTLS configures the remoting system to use a secure connection for communication with the specified remote node. This requires a TLS client configuration to enable secure interactions with the remote actor system.
Ensure that the remote actor system is configured with TLS enabled and capable of completing a successful handshake. It is recommended that both systems share the same root Certificate Authority (CA) for mutual trust and secure communication.
type SpawnRequest ¶
type SpawnRequest struct {
// Name represents the unique name of the actor.
// This name is used to identify and reference the actor across different nodes.
Name string
// Kind represents the type of the actor.
// It typically corresponds to the actor’s implementation within the system
Kind string
// Singleton specifies whether the actor is a singleton, meaning only one instance of the actor
// can exist across the entire cluster at any given time.
// This option is useful for actors responsible for global coordination or shared state.
// When Singleton is set to true it means that the given actor is automatically relocatable
Singleton bool
// Relocatable indicates whether the actor can be automatically relocated to another node
// if its current host node unexpectedly shuts down.
// By default, actors are relocatable to ensure system resilience and high availability.
// Setting this to false ensures that the actor will not be redeployed after a node failure,
// which may be necessary for actors with node-specific dependencies or state.
Relocatable bool
// PassivationStrategy sets the passivation strategy after which an actor
// will be passivated. Passivation allows the actor system to free up
// resources by stopping actors that have been inactive for the specified
// duration. If the actor receives a message before this timeout,
// the passivation timer is reset.
PassivationStrategy passivation.Strategy
// Dependencies define the list of dependencies that injects the given dependencies into
// the actor during its initialization.
//
// This allows you to configure an actor with one or more dependencies,
// such as services, clients, or configuration objects it needs to function.
// These dependencies will be made available to the actor when it is spawned,
// enabling better modularity and testability.
Dependencies []extension.Dependency
// EnableStashing enables stashing and sets the stash buffer for the actor, allowing it to temporarily store
// incoming messages that cannot be immediately processed. This is particularly useful
// in scenarios where the actor must delay handling certain messages—for example,
// during initialization, while awaiting external resources, or transitioning between states.
//
// By stashing messages, the actor can defer processing until it enters a stable or ready state,
// at which point the buffered messages can be retrieved and handled in a controlled sequence.
// This helps maintain a clean and predictable message flow without dropping or prematurely
// processing input.
//
// Use WithStashing when spawning the actor to activate this capability. By default, the stash
// buffer is disabled.
//
// ⚠️ Note: The stash buffer is *not* a substitute for robust message handling or proper
// supervision strategies. Misuse may lead to unbounded memory growth if messages are
// stashed but never unstashed. Always ensure the actor eventually processes or discards
// stashed messages to avoid leaks or state inconsistencies.
//
// When used correctly, the stash buffer is a powerful tool for managing transient states
// and preserving actor responsiveness while maintaining orderly message handling.
EnableStashing bool
}
SpawnRequest defines configuration options for spawning an actor on a remote node. These options control the actor’s identity, behavior, and lifecycle, especially in scenarios involving node failures or load balancing.
func (*SpawnRequest) Validate ¶
func (s *SpawnRequest) Validate() error
Validate validates the SpawnRequest