Skip to content

Commit

Permalink
Reorganize code
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Feb 2, 2025
1 parent 0196da5 commit c20557f
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions lib/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ type NatsConfig struct {
Server string `json:"natsServer"`
}

// NatsCredential represents the api response of the register licensed user api
type NatsCredential struct {
NatsConfig `json:",inline,omitempty"`
Credential []byte `json:"credential"`
}

type NatsClient struct {
cfg *rest.Config
clusterID string
Expand All @@ -64,14 +70,12 @@ type NatsClient struct {
mu sync.Mutex
}

// NatsCredential represents the api response of the register licensed user api
type NatsCredential struct {
NatsConfig `json:",inline,omitempty"`
Credential []byte `json:"credential"`
}

type LicenseIDGetter interface {
GetLicenseID() string
func NewNatsClient(cfg *rest.Config, clusterID string, LicenseFile string) *NatsClient {
return &NatsClient{
cfg: cfg,
clusterID: clusterID,
LicenseFile: LicenseFile,
}
}

func (c *NatsClient) Request(data []byte, timeout time.Duration) (*nats.Msg, error) {
Expand Down Expand Up @@ -123,14 +127,6 @@ func (c *NatsClient) GetLicenseID() string {
return c.l.ID
}

func NewNatsConfig(cfg *rest.Config, clusterID string, LicenseFile string) *NatsClient {
return &NatsClient{
cfg: cfg,
clusterID: clusterID,
LicenseFile: LicenseFile,
}
}

func (c *NatsClient) connect() error {
le, err := kubernetes.NewLicenseEnforcer(c.cfg, c.LicenseFile)
if err != nil {
Expand Down

0 comments on commit c20557f

Please sign in to comment.