Skip to content

Commit 62421e0

Browse files
authored
Expose nats connection (#57)
Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent 9226024 commit 62421e0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/nats.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ func (c *NatsClient) GetLicenseID() (string, error) {
133133
return c.l.ID, nil
134134
}
135135

136+
func (c *NatsClient) Connect() (*nats.Conn, error) {
137+
c.mu.Lock()
138+
defer c.mu.Unlock()
139+
140+
if c.nc == nil {
141+
if err := c.connect(); err != nil {
142+
return nil, err
143+
}
144+
}
145+
return c.nc, nil
146+
}
147+
136148
func (c *NatsClient) connect() error {
137149
le, err := kubernetes.NewLicenseEnforcer(c.cfg, c.LicenseFile)
138150
if err != nil {

0 commit comments

Comments
 (0)