Skip to content

Commit 52d2455

Browse files
committed
Fix interfaces
1 parent 91db586 commit 52d2455

File tree

10 files changed

+29
-8
lines changed

10 files changed

+29
-8
lines changed

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type Config struct {
4545
Plugin PluginConfig
4646
}
4747

48-
var _ IConfig = &Config{}
48+
var _ IConfig = (*Config)(nil)
4949

5050
func NewConfig(ctx context.Context, globalConfigFile, pluginConfigFile string) *Config {
5151
_, span := otel.Tracer(TracerName).Start(ctx, "Create new config")

metrics/merger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type Merger struct {
4444
OutputMetrics []byte
4545
}
4646

47-
var _ IMerger = &Merger{}
47+
var _ IMerger = (*Merger)(nil)
4848

4949
// NewMerger creates a new metrics merger.
5050
func NewMerger(

network/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type Client struct {
4444
Address string
4545
}
4646

47-
var _ IClient = &Client{}
47+
var _ IClient = (*Client)(nil)
4848

4949
// NewClient creates a new client.
5050
func NewClient(ctx context.Context, clientConfig *config.Client, logger zerolog.Logger) *Client {

network/conn_wrapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type ConnWrapper struct {
3737
handshakeTimeout time.Duration
3838
}
3939

40-
var _ IConnWrapper = &ConnWrapper{}
40+
var _ IConnWrapper = (*ConnWrapper)(nil)
4141

4242
// Conn returns the underlying connection.
4343
func (cw *ConnWrapper) Conn() net.Conn {

network/engine.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import (
1111
"github.com/rs/zerolog"
1212
)
1313

14+
type IEngine interface {
15+
CountConnections() int
16+
Stop(ctx context.Context) error
17+
}
18+
1419
// Engine is the network engine.
1520
// TODO: Move this to the Server struct.
1621
type Engine struct {
@@ -24,6 +29,8 @@ type Engine struct {
2429
mu *sync.RWMutex
2530
}
2631

32+
var _ IEngine = (*Engine)(nil)
33+
2734
// CountConnections returns the current number of connections.
2835
func (engine *Engine) CountConnections() int {
2936
engine.mu.RLock()

network/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type Proxy struct {
4949
ClientConfig *config.Client
5050
}
5151

52-
var _ IProxy = &Proxy{}
52+
var _ IProxy = (*Proxy)(nil)
5353

5454
// NewProxy creates a new proxy.
5555
func NewProxy(

network/server.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ const (
3333
Shutdown
3434
)
3535

36+
type IServer interface {
37+
OnBoot(engine Engine) Action
38+
OnOpen(conn *ConnWrapper) ([]byte, Action)
39+
OnClose(conn *ConnWrapper, err error) Action
40+
OnTraffic(conn *ConnWrapper, stopConnection chan struct{}) Action
41+
OnShutdown()
42+
OnTick() (time.Duration, Action)
43+
Run() *gerr.GatewayDError
44+
Shutdown()
45+
IsRunning() bool
46+
}
47+
3648
type Server struct {
3749
engine Engine
3850
proxy IProxy
@@ -55,6 +67,8 @@ type Server struct {
5567
HandshakeTimeout time.Duration
5668
}
5769

70+
var _ IServer = (*Server)(nil)
71+
5872
// OnBoot is called when the server is booted. It calls the OnBooting and OnBooted hooks.
5973
// It also sets the status to running, which is used to determine if the server should be running
6074
// or shutdown.

plugin/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type IPlugin interface {
1717
Ping() *gerr.GatewayDError
1818
}
1919

20-
var _ IPlugin = &Plugin{}
20+
var _ IPlugin = (*Plugin)(nil)
2121

2222
// Start starts the plugin.
2323
func (p *Plugin) Start() (net.Addr, error) {

plugin/plugin_registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type Registry struct {
6464
Termination config.TerminationPolicy
6565
}
6666

67-
var _ IRegistry = &Registry{}
67+
var _ IRegistry = (*Registry)(nil)
6868

6969
// NewRegistry creates a new plugin registry.
7070
func NewRegistry(

pool/pool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type Pool struct {
3030
ctx context.Context //nolint:containedctx
3131
}
3232

33-
var _ IPool = &Pool{}
33+
var _ IPool = (*Pool)(nil)
3434

3535
// ForEach iterates over the pool and calls the callback function for each key/value pair.
3636
func (p *Pool) ForEach(cb Callback) {

0 commit comments

Comments
 (0)