From fcc618c94158f0ed705373ec56ca89dbf5590b9d Mon Sep 17 00:00:00 2001 From: xh3b4sd Date: Sat, 30 Sep 2023 02:53:55 +0200 Subject: [PATCH] expose host:port the client is listening at (#9) --- interface.go | 3 ++- pkg/client/client.go | 6 ++++++ pkg/fake/client.go | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/interface.go b/interface.go index 3e137b7..8e2a69a 100644 --- a/interface.go +++ b/interface.go @@ -2,7 +2,6 @@ package redigo import ( "github.com/gomodule/redigo/redis" - "github.com/xh3b4sd/redigo/pkg/backup" "github.com/xh3b4sd/redigo/pkg/locker" "github.com/xh3b4sd/redigo/pkg/pubsub" @@ -18,6 +17,8 @@ type Interface interface { Purge() error Redis(fun func(con redis.Conn) error) error + Listen() string + Backup() backup.Interface Locker() locker.Interface PubSub() pubsub.Interface diff --git a/pkg/client/client.go b/pkg/client/client.go index ecaeaad..99117eb 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -39,6 +39,7 @@ type ConfigLocker struct { } type Client struct { + add string bac backup.Interface loc locker.Interface poo *redis.Pool @@ -155,6 +156,7 @@ func New(con Config) (*Client, error) { } c := &Client{ + add: con.Address, bac: bac, loc: loc, poo: con.Pool, @@ -228,6 +230,10 @@ func (c *Client) Redis(fun func(con redis.Conn) error) error { return nil } +func (c *Client) Listen() string { + return c.add +} + func (c *Client) Backup() backup.Interface { return c.bac } diff --git a/pkg/fake/client.go b/pkg/fake/client.go index 31cbc3e..24b0fee 100644 --- a/pkg/fake/client.go +++ b/pkg/fake/client.go @@ -44,6 +44,10 @@ func (c *Client) Redis(fun func(con redis.Conn) error) error { return nil } +func (c *Client) Listen() string { + return "" +} + func (c *Client) Backup() backup.Interface { if c.FakeLocker != nil { return c.FakeBackup()