Skip to content

Commit

Permalink
feat: Expose ConnectionString method in Client (#57)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hermanschaaf authored Jul 3, 2023
1 parent 828f90c commit 45b234e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions managedplugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type Client struct {
config Config
noSentry bool
metrics *Metrics
registry Registry
}

type Option func(*Client)
Expand Down Expand Up @@ -126,6 +127,7 @@ func NewClient(ctx context.Context, typ PluginType, config Config, opts ...Optio
wg: &sync.WaitGroup{},
config: config,
metrics: &Metrics{},
registry: config.Registry,
}
for _, opt := range opts {
opt(&c)
Expand Down Expand Up @@ -166,6 +168,19 @@ func NewClient(ctx context.Context, typ PluginType, config Config, opts ...Optio
return &c, nil
}

func (c *Client) ConnectionString() string {
tgt := c.Conn.Target()
switch c.registry {
case RegistryGrpc:
return tgt
case RegistryLocal:
return "unix://" + tgt
case RegistryGithub:
return "unix://" + tgt
}
return tgt
}

func (c *Client) Metrics() Metrics {
return *c.metrics
}
Expand Down

0 comments on commit 45b234e

Please sign in to comment.