Skip to content

Commit

Permalink
Add prefix in options of loki syncer
Browse files Browse the repository at this point in the history
  • Loading branch information
dongxuny committed Jan 28, 2022
1 parent d259170 commit a3e692c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions syncer_loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,33 @@ func WithLokiPassword(pass string) LokiSyncerOption {
}
}

// WithClientTls provide loki http client TLS config
func WithClientTls(conf *tls.Config) LokiSyncerOption {
// WithLokiClientTls provide loki http client TLS config
func WithLokiClientTls(conf *tls.Config) LokiSyncerOption {
return func(syncer *lokiSyncer) {
syncer.tlsConfig = conf
}
}

// WithLabel provide labels, should follow isValidLabelName()
func WithLabel(key, value string) LokiSyncerOption {
// WithLokiLabel provide labels, should follow isValidLabelName()
func WithLokiLabel(key, value string) LokiSyncerOption {
return func(syncer *lokiSyncer) {
if len(key) > 0 && len(value) > 0 {
syncer.labels[key] = value
}
}
}

// WithMaxBatchWaitMs provide max batch wait time in milli
func WithMaxBatchWaitMs(in time.Duration) LokiSyncerOption {
// WithLokiMaxBatchWaitMs provide max batch wait time in milli
func WithLokiMaxBatchWaitMs(in time.Duration) LokiSyncerOption {
return func(syncer *lokiSyncer) {
if in.Milliseconds() > 0 {
syncer.maxBatchWaitMs = in
}
}
}

// WithMaxBatchSize provide max batch size
func WithMaxBatchSize(batchSize int) LokiSyncerOption {
// WithLokiMaxBatchSize provide max batch size
func WithLokiMaxBatchSize(batchSize int) LokiSyncerOption {
return func(syncer *lokiSyncer) {
if batchSize > 0 {
syncer.maxBatchSize = batchSize
Expand Down
8 changes: 4 additions & 4 deletions syncer_loki_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ func TestNewLokiSyncer(t *testing.T) {
WithLokiPath("ut-path"),
WithLokiUsername("ut-name"),
WithLokiPassword("ut-pass"),
WithClientTls(&tls.Config{}),
WithLabel("key", "value"),
WithMaxBatchWaitMs(time.Second),
WithMaxBatchSize(10))
WithLokiClientTls(&tls.Config{}),
WithLokiLabel("key", "value"),
WithLokiMaxBatchWaitMs(time.Second),
WithLokiMaxBatchSize(10))
assert.Equal(t, "https://ut-addr", syncer.addr)
assert.Equal(t, "ut-path", syncer.path)
assert.NotEmpty(t, syncer.basicAuthHeader)
Expand Down

0 comments on commit a3e692c

Please sign in to comment.