Skip to content

Commit 45b234e

Browse files
authored
feat: Expose ConnectionString method in Client (#57)
Exposes a `ConnectionString` method that can be used to connect to the client via GRPC. It includes the protocol in the string so that GRPC clients can automatically infer the connection type.
1 parent 828f90c commit 45b234e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

managedplugin/plugin.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type Client struct {
6363
config Config
6464
noSentry bool
6565
metrics *Metrics
66+
registry Registry
6667
}
6768

6869
type Option func(*Client)
@@ -126,6 +127,7 @@ func NewClient(ctx context.Context, typ PluginType, config Config, opts ...Optio
126127
wg: &sync.WaitGroup{},
127128
config: config,
128129
metrics: &Metrics{},
130+
registry: config.Registry,
129131
}
130132
for _, opt := range opts {
131133
opt(&c)
@@ -166,6 +168,19 @@ func NewClient(ctx context.Context, typ PluginType, config Config, opts ...Optio
166168
return &c, nil
167169
}
168170

171+
func (c *Client) ConnectionString() string {
172+
tgt := c.Conn.Target()
173+
switch c.registry {
174+
case RegistryGrpc:
175+
return tgt
176+
case RegistryLocal:
177+
return "unix://" + tgt
178+
case RegistryGithub:
179+
return "unix://" + tgt
180+
}
181+
return tgt
182+
}
183+
169184
func (c *Client) Metrics() Metrics {
170185
return *c.metrics
171186
}

0 commit comments

Comments
 (0)