namespace

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultNamespace is used for compass single tenant applications
	DefaultNamespace = &Namespace{
		ID:       uuid.Nil,
		Name:     "default",
		State:    SharedState,
		Metadata: map[string]interface{}{},
	}
)

Functions

This section is empty.

Types

type DiscoveryRepository

type DiscoveryRepository interface {
	CreateNamespace(context.Context, *Namespace) error
}

type Namespace

type Namespace struct {
	ID uuid.UUID `json:"id"`
	// Name should be at least couple of letters ideally as it will be unique same as ID
	Name string `json:"name"`

	State    State                  `json:"state"`
	Metadata map[string]interface{} `json:"metadata"`
}

func (Namespace) String

func (n Namespace) String() string

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(logger log.Logger, storageRepo StorageRepository, discoveryRepo DiscoveryRepository) *Service

func (Service) Create

func (s Service) Create(ctx context.Context, namespace *Namespace) (string, error)

func (Service) GetByID

func (s Service) GetByID(ctx context.Context, id uuid.UUID) (*Namespace, error)

func (Service) GetByName

func (s Service) GetByName(ctx context.Context, name string) (*Namespace, error)

func (Service) List

func (s Service) List(ctx context.Context) ([]*Namespace, error)

func (Service) MigrateDefault

func (s Service) MigrateDefault(ctx context.Context) (string, error)

func (Service) Update

func (s Service) Update(ctx context.Context, namespace *Namespace) error

Update can't modify a namespace ID and name

type State

type State string
const (
	// PendingState could be used for tenants which are not ready for use at the moment
	PendingState State = "pending"
	// SharedState is used for default small scale tenants
	SharedState State = "shared"
	// DedicatedState is for large tenants
	DedicatedState State = "dedicated"
	// UpgradeState is used when a shared tenant is getting upgraded to dedicated
	// TODO: *impt* : support of upgrading a shared to dedicated tenant is not implemented yet
	UpgradeState State = "upgrade"
)

func (State) String

func (s State) String() string

type StorageRepository

type StorageRepository interface {
	Create(context.Context, *Namespace) (string, error)
	Update(context.Context, *Namespace) error
	GetByID(context.Context, uuid.UUID) (*Namespace, error)
	GetByName(context.Context, string) (*Namespace, error)
	List(context.Context) ([]*Namespace, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL