Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add string representation of boltdb shipper mode #5982

Merged
merged 1 commit into from
Apr 21, 2022
Merged
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
20 changes: 17 additions & 3 deletions pkg/storage/stores/shipper/shipper_index_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ import (
"github.com/grafana/loki/pkg/util/spanlogger"
)

type Mode int

const (
// ModeReadWrite is to allow both read and write
ModeReadWrite = iota
ModeReadWrite Mode = iota
// ModeReadOnly is to allow only read operations
ModeReadOnly
// ModeWriteOnly is to allow only write operations
Expand All @@ -42,6 +44,18 @@ const (
UploadInterval = 1 * time.Minute
)

func (m Mode) String() string {
switch m {
case ModeReadWrite:
return "read-write"
case ModeReadOnly:
return "read-only"
case ModeWriteOnly:
return "write-only"
}
return "unknown"
}

type boltDBIndexClient interface {
QueryWithCursor(_ context.Context, c *bbolt.Cursor, query index.Query, callback index.QueryPagesCallback) error
NewWriteBatch() index.WriteBatch
Expand All @@ -60,7 +74,7 @@ type Config struct {
IndexGatewayClientConfig IndexGatewayClientConfig `yaml:"index_gateway_client"`
BuildPerTenantIndex bool `yaml:"build_per_tenant_index"`
IngesterName string `yaml:"-"`
Mode int `yaml:"-"`
Mode Mode `yaml:"-"`
IngesterDBRetainPeriod time.Duration `yaml:"-"`
}

Expand Down Expand Up @@ -104,7 +118,7 @@ func NewShipper(cfg Config, storageClient client.ObjectClient, limits downloads.
return nil, err
}

level.Info(util_log.Logger).Log("msg", fmt.Sprintf("starting boltdb shipper in %d mode", cfg.Mode))
level.Info(util_log.Logger).Log("msg", fmt.Sprintf("starting boltdb shipper in %s mode", cfg.Mode))

return &shipper, nil
}
Expand Down