From 5a156cc6992f6e791a30d70c79ea375e34871505 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Fri, 18 Nov 2022 02:01:18 -0800 Subject: [PATCH] gateway: Expose GatewayOpts getter --- gateway/gateway.go | 6 +++++- utils/ws/gateway.go | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gateway/gateway.go b/gateway/gateway.go index 5662de1..76ae29a 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -171,13 +171,17 @@ func NewFromState(gatewayURL string, state State, opts *ws.GatewayOpts) *Gateway } gw := ws.NewGateway(ws.NewWebsocket(ws.NewCodec(OpUnmarshalers), gatewayURL), opts) - return &Gateway{ gateway: gw, state: state, } } +// Opts returns a copy of the gateway options that are being used. +func (g *Gateway) Opts() *ws.GatewayOpts { + return g.gateway.Opts() +} + // State returns a copy of the gateway's internal state. It panics if the // gateway is currently running. func (g *Gateway) State() State { diff --git a/utils/ws/gateway.go b/utils/ws/gateway.go index d5de4ba..077d833 100644 --- a/utils/ws/gateway.go +++ b/utils/ws/gateway.go @@ -159,6 +159,13 @@ func NewGateway(ws *Websocket, opts *GatewayOpts) *Gateway { } } +// Opts returns a copy of the gateway options. The options can only be changed +// during construction, so a copy is a must. +func (g *Gateway) Opts() *GatewayOpts { + cpy := g.opts + return &cpy +} + // Send is a function to send an Op payload to the Gateway. func (g *Gateway) Send(ctx context.Context, data Event) error { op := Op{