mirror of
https://github.com/hanzoai/o11y.git
synced 2026-11-02 09:37:36 +00:00
Full rebrand of the SigNoz observability platform: - Go module: github.com/SigNoz/signoz → github.com/hanzoai/o11y - Frontend: @signozhq/* → @hanzo/o11y-*, posthog-js → @hanzo/insights - Docker: signoz/* → ghcr.io/hanzoai/o11y* - ClickHouse → Hanzo Datastore (hanzoai/datastore) - Env vars: SIGNOZ_* → HANZO_* - DB tables: signoz_* → o11y_* - All branding, URLs, docs updated - 2172 files changed
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package singlesharder
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hanzoai/o11y/pkg/errors"
|
|
"github.com/hanzoai/o11y/pkg/factory"
|
|
"github.com/hanzoai/o11y/pkg/sharder"
|
|
"github.com/hanzoai/o11y/pkg/types"
|
|
"github.com/hanzoai/o11y/pkg/valuer"
|
|
)
|
|
|
|
type provider struct {
|
|
settings factory.ScopedProviderSettings
|
|
orgID valuer.UUID
|
|
orgIDKey uint32
|
|
}
|
|
|
|
func NewFactory() factory.ProviderFactory[sharder.Sharder, sharder.Config] {
|
|
return factory.NewProviderFactory(factory.MustNewName("single"), New)
|
|
}
|
|
|
|
func New(ctx context.Context, providerSettings factory.ProviderSettings, config sharder.Config) (sharder.Sharder, error) {
|
|
settings := factory.NewScopedProviderSettings(providerSettings, "github.com/hanzoai/o11y/pkg/sharder/singlesharder")
|
|
|
|
return &provider{
|
|
settings: settings,
|
|
orgID: config.Single.OrgID,
|
|
orgIDKey: types.NewOrganizationKey(config.Single.OrgID),
|
|
}, nil
|
|
}
|
|
|
|
func (provider *provider) GetMyOwnedKeyRange(ctx context.Context) (uint32, uint32, error) {
|
|
return provider.orgIDKey, provider.orgIDKey, nil
|
|
}
|
|
|
|
func (provider *provider) IsMyOwnedKey(ctx context.Context, key uint32) error {
|
|
if key == provider.orgIDKey {
|
|
return nil
|
|
}
|
|
|
|
return errors.Newf(errors.TypeForbidden, errors.CodeForbidden, "key %d for org %s is not owned by my current instance", key, provider.orgID)
|
|
}
|