gate

package
v2.6.4 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 31 Imported by: 7

Documentation

Overview

Package gate implements the gate server component.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gate

type Gate struct {
	component.Base
	// contains filtered or unexported fields
}

Gate is the gate server component.

func NewGate

func NewGate(opts ...Option) *Gate

NewGate returns a new gate server component configured by the given options.

func (*Gate) Close added in v2.2.3

func (g *Gate) Close()

Close closes the gate.

It switches the state to Hang and refreshes the service instance state, then waits for all online client sessions to exit naturally (graceful shutdown semantics).

func (*Gate) Destroy

func (g *Gate) Destroy()

Destroy destroys the component.

It deregisters the service instance, stops the network server and the link server in turn, and cancels the component context.

func (*Gate) Init

func (g *Gate) Init()

Init initializes the component.

It validates whether the instance ID and the required components (server, locator and registry) have been injected.

func (*Gate) Name

func (g *Gate) Name() string

Name returns the component name.

func (*Gate) Start

func (g *Gate) Start()

Start starts the component.

It starts the network server and the internal link server in turn, registers the service instance, watches user locations and cluster instances, and prints the component information.

type Option

type Option func(o *options)

Option is a gate option.

func WithAddr added in v2.3.0

func WithAddr(addr string) Option

WithAddr sets the listen address.

func WithContext

func WithContext(ctx context.Context) Option

WithContext sets the context.

func WithDispatch added in v2.3.0

func WithDispatch(dispatch cluster.Dispatch) Option

WithDispatch sets the dispatch strategy of stateless route messages.

func WithExpose added in v2.3.0

func WithExpose(expose bool) Option

WithExpose sets whether the internal communication address is exposed to the public network.

func WithID

func WithID(id string) Option

WithID sets the instance ID.

func WithLinkerCallTimeout added in v2.6.0

func WithLinkerCallTimeout(callTimeout time.Duration) Option

WithLinkerCallTimeout sets the RPC call timeout.

func WithLinkerCommandQueueSize added in v2.6.0

func WithLinkerCommandQueueSize(commandQueueSize int32) Option

WithLinkerCommandQueueSize sets the message queue size.

func WithLinkerCommandWriteTimeout added in v2.6.0

func WithLinkerCommandWriteTimeout(commandWriteTimeout time.Duration) Option

WithLinkerCommandWriteTimeout sets the write timeout.

func WithLinkerConnNum added in v2.6.0

func WithLinkerConnNum(connNum int) Option

WithLinkerConnNum sets the number of connections.

func WithLinkerDialRetryTimes added in v2.6.0

func WithLinkerDialRetryTimes(dialRetryTimes int) Option

WithLinkerDialRetryTimes sets the number of internal RPC dial retries.

func WithLinkerDialTimeout added in v2.6.0

func WithLinkerDialTimeout(dialTimeout time.Duration) Option

WithLinkerDialTimeout sets the internal RPC dial timeout.

func WithLinkerFaultRecoveryTime added in v2.6.0

func WithLinkerFaultRecoveryTime(faultRecoveryTime time.Duration) Option

WithLinkerFaultRecoveryTime sets the internal RPC fault recovery time.

func WithLocator

func WithLocator(locator locate.Locator) Option

WithLocator sets the user locator.

func WithMetadata added in v2.3.0

func WithMetadata(metadata map[string]string) Option

WithMetadata sets the metadata.

func WithName

func WithName(name string) Option

WithName sets the instance name.

func WithRegistry

func WithRegistry(r registry.Registry) Option

WithRegistry sets the service registry.

func WithServer

func WithServer(server network.Server) Option

WithServer sets the server.

func WithSessionSecurity added in v2.6.3

func WithSessionSecurity(signer crypto.Signer, suites ...aead.Suite) Option

WithSessionSecurity enables the session security between the client and the gate.

signer signs the ServerHello so that the client can verify the gate with the pinned public key. When no suite is given, the handshake defaults are used. When enabled, the payload of client messages is decrypted by the gate and re-encrypted for the downlink, so the node-side static encryptor must stay unconfigured.

func WithSessionSecurityHandshakeTimeout added in v2.6.3

func WithSessionSecurityHandshakeTimeout(timeout time.Duration) Option

WithSessionSecurityHandshakeTimeout sets how long the gate waits for a client to complete the session security handshake. A zero duration disables the timeout.

Jump to

Keyboard shortcuts

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