Documentation
¶
Index ¶
- Variables
- func RespondSessionError(s *api.Session, err error)
- type ClientSessionOptions
- type ClientSessions
- func (m *ClientSessions) Close(ctx context.Context) error
- func (m *ClientSessions) Count(uid int64) int
- func (m *ClientSessions) End(ctx context.Context, uid int64, ref *proxypb.ClientSessionRef, ...) error
- func (m *ClientSessions) Expire(ctx context.Context) error
- func (m *ClientSessions) Open(ctx context.Context, uid int64, ref *proxypb.ClientSessionRef) error
- func (m *ClientSessions) RegisterHeartbeat(reg *api.Registry) error
- func (m *ClientSessions) RegisterRPC(reg *api.Registry) error
- func (m *ClientSessions) Renew(ctx context.Context, uid int64, ref *proxypb.ClientSessionRef) error
- func (m *ClientSessions) RenewCaller(s *api.Session) error
- func (m *ClientSessions) Run(ctx context.Context) error
- func (m *ClientSessions) Validate(ctx context.Context, uid int64, ref *proxypb.ClientSessionRef) error
- func (m *ClientSessions) ValidateCaller(s *api.Session) error
- type Delivery
- func (d *Delivery) Add(conn proxy.Connection) error
- func (d *Delivery) Broadcast(ctx context.Context, connIDs []string, msg rpc.Message) error
- func (d *Delivery) Close(ctx context.Context, connID string) error
- func (d *Delivery) CloseAll(ctx context.Context) error
- func (d *Delivery) Remove(connID string) bool
- func (d *Delivery) Send(ctx context.Context, connID string, msg rpc.Message) error
- type Gateway
- func (g *Gateway) Accept(ctx context.Context, conn proxy.Connection, req proxy.AuthRequest) (Session, error)
- func (g *Gateway) AcceptIdentity(conn proxy.Connection, identity proxy.Identity) (Session, error)
- func (g *Gateway) ConnectionIDs(uid int64) []string
- func (g *Gateway) Disconnect(connID string) bool
- func (g *Gateway) DisconnectSession(connID string) (Session, bool)
- func (g *Gateway) MembershipLock() sync.Locker
- func (g *Gateway) Receive(ctx context.Context, connID string, msg rpc.Message) error
- func (g *Gateway) Session(connID string) (Session, bool)
- func (g *Gateway) Sessions() []Session
- func (g *Gateway) SessionsByUID(uid int64) []Session
- type RPCSessionLifecycle
- type RPCUpstream
- type Session
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func RespondSessionError ¶ added in v0.3.0
RespondSessionError completes the original RPC with a stable liveness error.
Types ¶
type ClientSessionOptions ¶ added in v0.3.0
type ClientSessionOptions struct {
TTL time.Duration
Now func() time.Time
OnOpened func(context.Context, int64, *proxypb.ClientSessionRef) error
OnClosed func(context.Context, int64, *proxypb.ClientSessionRef, proxypb.SessionEndReason) error
}
ClientSessionOptions controls ephemeral, per-connection liveness. Hooks run without the lease lock and must not assume a loaded business User.
type ClientSessions ¶ added in v0.3.0
type ClientSessions struct {
// contains filtered or unexported fields
}
ClientSessions owns leases, not business users or sockets. Explicit Open is the only operation that creates a lease. Renew cannot resurrect a closed connection.
func NewClientSessions ¶ added in v0.3.0
func NewClientSessions(opts ClientSessionOptions) *ClientSessions
NewClientSessions creates a component with no implicit background goroutine.
func (*ClientSessions) Close ¶ added in v0.3.0
func (m *ClientSessions) Close(ctx context.Context) error
Close retires all live references and rejects further activation.
func (*ClientSessions) Count ¶ added in v0.3.0
func (m *ClientSessions) Count(uid int64) int
Count reports currently live connections without loading a User or renewing.
func (*ClientSessions) End ¶ added in v0.3.0
func (m *ClientSessions) End(ctx context.Context, uid int64, ref *proxypb.ClientSessionRef, reason proxypb.SessionEndReason) error
End is idempotent and closes only one full connection reference. A close that arrives before Open retires the reference as well, preventing reordered activation.
func (*ClientSessions) Expire ¶ added in v0.3.0
func (m *ClientSessions) Expire(ctx context.Context) error
Expire removes elapsed leases and old retirement markers. Retired references are retained at least as long as a bounded lifecycle RPC can remain in flight. Heartbeats always reject unknown references, including after marker collection.
func (*ClientSessions) Open ¶ added in v0.3.0
func (m *ClientSessions) Open(ctx context.Context, uid int64, ref *proxypb.ClientSessionRef) error
Open accepts only a previously authenticated live proxy reference. Repeated Open is idempotent and does not renew; a different UID cannot steal the same reference.
func (*ClientSessions) RegisterHeartbeat ¶ added in v0.3.0
func (m *ClientSessions) RegisterHeartbeat(reg *api.Registry) error
RegisterHeartbeat provides an optional pure framework heartbeat. Business heartbeats use their own PB, validate business conditions, then call RenewCaller.
func (*ClientSessions) RegisterRPC ¶ added in v0.3.0
func (m *ClientSessions) RegisterRPC(reg *api.Registry) error
RegisterRPC binds proxy-only lifecycle messages to the UID's business owner. These handlers do not load, create, or mark a business User active.
func (*ClientSessions) Renew ¶ added in v0.3.0
func (m *ClientSessions) Renew(ctx context.Context, uid int64, ref *proxypb.ClientSessionRef) error
Renew extends only the exact, already-live UID/reference binding.
func (*ClientSessions) RenewCaller ¶ added in v0.3.0
func (m *ClientSessions) RenewCaller(s *api.Session) error
RenewCaller renews only the trusted connection associated with this invocation.
func (*ClientSessions) Run ¶ added in v0.3.0
func (m *ClientSessions) Run(ctx context.Context) error
Run owns the expiry loop; the application invokes it in its service lifecycle.
func (*ClientSessions) Validate ¶ added in v0.3.0
func (m *ClientSessions) Validate(ctx context.Context, uid int64, ref *proxypb.ClientSessionRef) error
Validate checks liveness without extending the deadline.
func (*ClientSessions) ValidateCaller ¶ added in v0.3.0
func (m *ClientSessions) ValidateCaller(s *api.Session) error
ValidateCaller verifies the current invocation's exact connection without renewing it.
type Delivery ¶
type Delivery struct {
// contains filtered or unexported fields
}
Delivery 跟踪用于下行消息的存活传输连接。
func (*Delivery) Add ¶
func (d *Delivery) Add(conn proxy.Connection) error
Add 按 ID 注册一个连接,并拒绝重复所有权。
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway 拥有已认证客户端 Session,并转发上行消息;它不了解 Player、World、DBPlayer 或 feature Module。
func NewGateway ¶
func NewGateway(auth proxy.Authenticator, upstream proxy.Upstream) *Gateway
NewGateway 创建带空连接索引和 UID 索引的 proxy Gateway。
func (*Gateway) Accept ¶
func (g *Gateway) Accept(ctx context.Context, conn proxy.Connection, req proxy.AuthRequest) (Session, error)
Accept 认证并注册一个连接。
func (*Gateway) AcceptIdentity ¶
AcceptIdentity 直接按已认证身份注册连接。
func (*Gateway) ConnectionIDs ¶
ConnectionIDs 返回 uid 当前已认证的连接 ID 列表。
func (*Gateway) Disconnect ¶
Disconnect 从 Session 注册表移除一个连接。
func (*Gateway) DisconnectSession ¶
DisconnectSession 从 Session 注册表移除一个连接,并返回被移除的 Session。
func (*Gateway) MembershipLock ¶ added in v0.3.0
MembershipLock coordinates adapter admission and first/last UID subscription changes across every server sharing this gateway. Do not hold it over business RPC, lifecycle hooks or socket writes. It is not the registry's internal lock.
func (*Gateway) Sessions ¶ added in v0.3.0
Sessions returns detached connection metadata for orderly proxy shutdown.
func (*Gateway) SessionsByUID ¶
SessionsByUID 返回 uid 当前已认证的 Session 快照。
type RPCSessionLifecycle ¶ added in v0.3.0
RPCSessionLifecycle binds a live authenticated proxy to the business owner's lifecycle routes. Local and NATS buses use the same messages and metadata.
func NewRPCSessionLifecycle ¶ added in v0.3.0
func NewRPCSessionLifecycle(bus rpc.Bus) *RPCSessionLifecycle
NewRPCSessionLifecycle creates the standard proxy lifecycle adapter.
func (*RPCSessionLifecycle) OnConnect ¶ added in v0.3.0
func (l *RPCSessionLifecycle) OnConnect(ctx context.Context, session Session) error
OnConnect waits for the business owner to accept this exact connection lease.
func (*RPCSessionLifecycle) OnDisconnect ¶ added in v0.3.0
func (l *RPCSessionLifecycle) OnDisconnect(ctx context.Context, session Session, reason proxypb.SessionEndReason) error
OnDisconnect notifies the owner; expiry is the fallback when delivery fails.
type RPCUpstream ¶
RPCUpstream 将已认证客户端消息转发到 aifd-rpc Bus。
func NewRPCUpstream ¶
func NewRPCUpstream(bus rpc.Bus, delivery *Delivery) *RPCUpstream
NewRPCUpstream 创建使用指定 Bus 的上行转发器。