Documentation
¶
Overview ¶
Package gate implements the gate server component.
Index ¶
- type Gate
- type Option
- func WithAddr(addr string) Option
- func WithContext(ctx context.Context) Option
- func WithDispatch(dispatch cluster.Dispatch) Option
- func WithExpose(expose bool) Option
- func WithGuardAcceptRate(quota float64, period time.Duration) Option
- func WithGuardMaxBanDuration(duration time.Duration) Option
- func WithGuardMaxConns(maxConns int) Option
- func WithGuardMaxEntries(maxEntries int) Option
- func WithGuardMinBanDuration(duration time.Duration) Option
- func WithGuardStrikeThreshold(threshold int) Option
- func WithGuardStrikeWindow(window time.Duration) Option
- func WithGuardWhitelist(whitelist []string) Option
- func WithID(id string) Option
- func WithLimiterBurst(burst int) Option
- func WithLimiterCloseThreshold(threshold int) Option
- func WithLimiterPeriod(period time.Duration) Option
- func WithLimiterQuota(quota float64) Option
- func WithLinkerCallTimeout(callTimeout time.Duration) Option
- func WithLinkerCommandQueueSize(commandQueueSize int32) Option
- func WithLinkerCommandWriteTimeout(commandWriteTimeout time.Duration) Option
- func WithLinkerConnNum(connNum int) Option
- func WithLinkerDialRetryTimes(dialRetryTimes int) Option
- func WithLinkerDialTimeout(dialTimeout time.Duration) Option
- func WithLinkerFaultRecoveryTime(faultRecoveryTime time.Duration) Option
- func WithLocator(locator locate.Locator) Option
- func WithMetadata(metadata map[string]string) Option
- func WithName(name string) Option
- func WithRegistry(r registry.Registry) Option
- func WithServer(server network.Server) Option
- func WithSessionSecurity(signer crypto.Signer, suites ...aead.Suite) Option
- func WithSessionSecurityHandshakeTimeout(timeout time.Duration) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Gate ¶
Gate is the gate server component.
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, closes the clients to the business nodes, and cancels the component context.
type Option ¶
type Option func(o *options)
Option is a gate option.
func WithDispatch ¶ added in v2.3.0
WithDispatch sets the dispatch strategy of stateless route messages.
func WithExpose ¶ added in v2.3.0
WithExpose sets whether the internal communication address is exposed to the public network.
func WithGuardAcceptRate ¶ added in v2.6.7
WithGuardAcceptRate sets the connection admission rate per IP. A zero quota disables the limit.
func WithGuardMaxBanDuration ¶ added in v2.6.7
WithGuardMaxBanDuration sets the maximum ban duration. A non-positive duration is ignored.
func WithGuardMaxConns ¶ added in v2.6.7
WithGuardMaxConns sets the maximum number of concurrent connections allowed per IP. A zero value disables the limit.
func WithGuardMaxEntries ¶ added in v2.6.7
WithGuardMaxEntries sets the maximum number of IP entries retained by the guard. A non-positive value is ignored.
func WithGuardMinBanDuration ¶ added in v2.6.7
WithGuardMinBanDuration sets the first ban duration. A non-positive duration is ignored.
func WithGuardStrikeThreshold ¶ added in v2.6.7
WithGuardStrikeThreshold sets the number of violations within the strike window that triggers a ban. Violations include connection admission rejections and, when the connection limiter is enabled, close signals emitted by the message rate limiter. A zero threshold disables automatic bans.
func WithGuardStrikeWindow ¶ added in v2.6.7
WithGuardStrikeWindow sets the strike window.
func WithGuardWhitelist ¶ added in v2.6.7
WithGuardWhitelist sets the IP whitelist.
func WithLimiterBurst ¶ added in v2.6.7
WithLimiterBurst sets the rate limit burst.
func WithLimiterCloseThreshold ¶ added in v2.6.7
WithLimiterCloseThreshold sets the number of consecutive limited messages that closes the connection. A zero threshold disables closing.
func WithLimiterPeriod ¶ added in v2.6.7
WithLimiterPeriod sets the rate limit period.
func WithLimiterQuota ¶ added in v2.6.7
WithLimiterQuota sets the rate limit quota. A zero quota disables rate limiting and overrides a quota configured through etc.
The limit applies to business frames only. Heartbeat frames are handled before the receive handler. When session security is enabled, handshake frames are routed to the security manager and also bypass the limit.
func WithLinkerCallTimeout ¶ added in v2.6.0
WithLinkerCallTimeout sets the RPC call timeout.
func WithLinkerCommandQueueSize ¶ added in v2.6.0
WithLinkerCommandQueueSize sets the message queue size.
func WithLinkerCommandWriteTimeout ¶ added in v2.6.0
WithLinkerCommandWriteTimeout sets the write timeout.
func WithLinkerConnNum ¶ added in v2.6.0
WithLinkerConnNum sets the number of connections.
func WithLinkerDialRetryTimes ¶ added in v2.6.0
WithLinkerDialRetryTimes sets the number of internal RPC dial retries.
func WithLinkerDialTimeout ¶ added in v2.6.0
WithLinkerDialTimeout sets the internal RPC dial timeout.
func WithLinkerFaultRecoveryTime ¶ added in v2.6.0
WithLinkerFaultRecoveryTime sets the internal RPC fault recovery time.
func WithLocator ¶
WithLocator sets the user locator.
func WithMetadata ¶ added in v2.3.0
WithMetadata sets the metadata.
func WithRegistry ¶
WithRegistry sets the service registry.
func WithSessionSecurity ¶ added in v2.6.3
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
WithSessionSecurityHandshakeTimeout sets how long the gate waits for a client to complete the session security handshake. A zero duration disables the timeout.