v1.35.3 Latest Latest

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

Go to latest
Published: Apr 12, 2024 License: MPL-2.0 Imports: 7 Imported by: 0




This section is empty.


View Source
var (
	ErrNotFound = errors.New("namespace not found")
	ErrActive   = errors.New("namespace is active")


This section is empty.


type DeletionHandler

type DeletionHandler interface {
	// CanDeleteNamespace is called to determine whether the namespace can be deleted
	// by the component. To signal the namespace cannot be deleted, return a non-nil error.
	CanDeleteNamespace(ctx context.Context, app *apps.Instance, ns *Namespace) error

	// DeleteNamespace is called when a namespace is deleted.
	// Due to the non-atomic nature of many components, failure to handle
	// the deletion cannot be fully rolled back.
	DeleteNamespace(ctx context.Context, app *apps.Instance, ns *Namespace) error

DeletionHandler is the interface for components that want to listen for and handle namespace deletion events.

type ID

type ID string

type Manager

type Manager struct {
	// contains filtered or unexported fields

Manager manages namespaces.

func NewManager

func NewManager(db *sql.DB) *Manager

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, app *apps.Instance, name Name) (*Namespace, error)

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, app *apps.Instance, name Name) error

func (*Manager) GetActive

func (m *Manager) GetActive(ctx context.Context, app *apps.Instance) (*Namespace, error)

GetActive returns the active namespace for the given app.

func (*Manager) GetByID

func (m *Manager) GetByID(ctx context.Context, app *apps.Instance, id ID) (*Namespace, error)

func (*Manager) GetByName

func (m *Manager) GetByName(ctx context.Context, app *apps.Instance, name Name) (*Namespace, error)

func (*Manager) List

func (m *Manager) List(ctx context.Context, app *apps.Instance) ([]*Namespace, error)

func (*Manager) RegisterDeletionHandler

func (mgr *Manager) RegisterDeletionHandler(h DeletionHandler)

func (*Manager) Switch

func (m *Manager) Switch(ctx context.Context, app *apps.Instance, name Name) (*Namespace, error)

type Name

type Name string

type Namespace

type Namespace struct {
	ID           ID
	App          *apps.Instance
	Name         Name
	Active       bool
	CreatedAt    time.Time
	LastActiveAt *time.Time

func (*Namespace) ToProto

func (ns *Namespace) ToProto() *daemonpb.Namespace

Jump to

Keyboard shortcuts

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