Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ func NewServiceExport(name string, subject string) (ServiceExport, error) {
}, nil
}

func (b *ServiceExportImpl) Tracing() *TracingConfiguration {
func (b *ServiceExportImpl) GetLatencyOptions() *LatencyOpts {
lat := b.export.Latency
if lat == nil {
return nil
}
return &TracingConfiguration{
return &LatencyOpts{
SamplingRate: SamplingRate(lat.Sampling),
Subject: string(lat.Results),
}
}

func (b *ServiceExportImpl) SetTracing(t *TracingConfiguration) error {
func (b *ServiceExportImpl) SetLatencyOptions(t *LatencyOpts) error {
if t == nil {
b.export.Latency = nil
} else {
Expand Down
4 changes: 2 additions & 2 deletions imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ func (b *baseImportImpl) Type() jwt.ExportType {
return b.in.Type
}

func (b *baseImportImpl) IsTraceable() bool {
func (b *baseImportImpl) IsShareConnectionInfo() bool {
return b.in.Share
}

func (b *baseImportImpl) SetTraceable(t bool) error {
func (b *baseImportImpl) SetShareConnectionInfo(t bool) error {
b.in.Share = t
return b.update()
}
22 changes: 11 additions & 11 deletions tests/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,14 @@ func (t *ProviderSuite) Test_ServiceExportTracing() {
service, err := a.Exports().Services().Add("q", "q.>")
t.NoError(err)

t.Nil(service.Tracing())
t.Nil(service.GetLatencyOptions())

t.NoError(service.SetTracing(&authb.TracingConfiguration{
t.NoError(service.SetLatencyOptions(&authb.LatencyOpts{
SamplingRate: 100,
Subject: "tracing.q",
}))

tc := service.Tracing()
tc := service.GetLatencyOptions()
t.NotNil(tc)
t.Equal(authb.SamplingRate(100), tc.SamplingRate)
t.Equal("tracing.q", tc.Subject)
Expand All @@ -316,20 +316,20 @@ func (t *ProviderSuite) Test_ServiceExportTracing() {
a = t.GetAccount(auth, "O", "A")
service = a.Exports().Services().Get("q.>")

tc = service.Tracing()
tc = service.GetLatencyOptions()
t.NotNil(tc)
t.Equal(authb.SamplingRate(100), tc.SamplingRate)
t.Equal("tracing.q", tc.Subject)

t.NoError(service.SetTracing(nil))
t.Nil(service.Tracing())
t.NoError(service.SetLatencyOptions(nil))
t.Nil(service.GetLatencyOptions())

t.NoError(auth.Commit())
t.NoError(auth.Reload())

a = t.GetAccount(auth, "O", "A")
service = a.Exports().Services().Get("q.>")
tc = service.Tracing()
tc = service.GetLatencyOptions()
t.Nil(tc)
}

Expand All @@ -341,19 +341,19 @@ func (t *ProviderSuite) Test_ServiceExportTracingRejectsBadOptions() {
service, err := a.Exports().Services().Add("q", "q.>")
t.NoError(err)

t.Nil(service.Tracing())
t.Nil(service.GetLatencyOptions())

t.Error(service.SetTracing(&authb.TracingConfiguration{
t.Error(service.SetLatencyOptions(&authb.LatencyOpts{
SamplingRate: 0,
Subject: "",
}))

t.Error(service.SetTracing(&authb.TracingConfiguration{
t.Error(service.SetLatencyOptions(&authb.LatencyOpts{
SamplingRate: 1,
Subject: "",
}))

t.Error(service.SetTracing(&authb.TracingConfiguration{
t.Error(service.SetLatencyOptions(&authb.LatencyOpts{
SamplingRate: 101,
Subject: "hello",
}))
Expand Down
10 changes: 5 additions & 5 deletions tests/imports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ func (t *ProviderSuite) Test_ServiceImportTraceable() {
akp := t.AccountKey()
service, err := a.Imports().Services().Add("q", akp.Public, "q.>")
t.NoError(err)
t.False(service.IsTraceable())
t.NoError(service.SetTraceable(true))
t.True(service.IsTraceable())
t.False(service.IsShareConnectionInfo())
t.NoError(service.SetShareConnectionInfo(true))
t.True(service.IsShareConnectionInfo())
}

func (t *ProviderSuite) Test_StreamImportTraceable() {
Expand All @@ -233,9 +233,9 @@ func (t *ProviderSuite) Test_StreamImportTraceable() {
akp := t.AccountKey()
stream, err := a.Imports().Streams().Add("q", akp.Public, "q.>")
t.NoError(err)
t.False(stream.IsTraceable())
t.False(stream.IsShareConnectionInfo())
// FIXME: current JWT doesn't allow traceable outside of services
t.Error(stream.SetTraceable(true))
t.Error(stream.SetShareConnectionInfo(true))
}

func (t *ProviderSuite) Test_NewServiceImportNameRequired() {
Expand Down
14 changes: 7 additions & 7 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,17 +467,17 @@ type Export interface {

type SamplingRate int

type TracingConfiguration struct {
type LatencyOpts struct {
SamplingRate SamplingRate
Subject string
}

type ServiceExport interface {
Export
// Tracing returns the TracingConfiguration if enabled otherwise nil
Tracing() *TracingConfiguration
// SetTracing enables tracing for the service, if nil, the tracing is disabled
SetTracing(config *TracingConfiguration) error
// GetLatencyOptions returns the LatencyOpts if enabled otherwise nil
GetLatencyOptions() *LatencyOpts
// SetLatencyOptions enables latency tracing for a service, if nil, the latency tracing is disabled
SetLatencyOptions(config *LatencyOpts) error
// GenerateImport generates an import that can be added to an Account
GenerateImport() (ServiceImport, error)
}
Expand All @@ -495,8 +495,8 @@ type Import interface {
SetToken(t string) error
LocalSubject() string
SetLocalSubject(subject string) error
IsTraceable() bool
SetTraceable(tf bool) error
IsShareConnectionInfo() bool
SetShareConnectionInfo(tf bool) error
}

type StreamImport interface {
Expand Down