nodebinding

package
v0.0.0-...-e2755d2 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Prefix for all node keys in the registry
	Prefix = "nodebinding/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Core

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

Core implements all business logic for nodebinding

func (*Core) CreateNodeBinding

func (c *Core) CreateNodeBinding(ctx context.Context, m *Model) error

CreateNodeBinding creates a new nodebinding

func (*Core) DeleteNodeBinding

func (c *Core) DeleteNodeBinding(ctx context.Context, key string, m *Model) error

DeleteNodeBinding deletes a nodebinding and all resources in it

func (*Core) Exists

func (c *Core) Exists(ctx context.Context, key string) (bool, error)

Exists to check if the nodebinding exists with fully qualified consul key

func (*Core) List

func (c *Core) List(ctx context.Context, prefix string) ([]*Model, error)

List gets all nodebinding keys starting with given prefix

func (*Core) ListKeys

func (c *Core) ListKeys(ctx context.Context, prefix string) ([]string, error)

ListKeys gets all nodebinding keys

func (*Core) TriggerNodeBindingRefresh

func (c *Core) TriggerNodeBindingRefresh(ctx context.Context) error

TriggerNodeBindingRefresh enables devs to refresh nodebindings manually

type ICore

type ICore interface {
	CreateNodeBinding(ctx context.Context, m *Model) error
	Exists(ctx context.Context, key string) (bool, error)
	DeleteNodeBinding(ctx context.Context, key string, m *Model) error
	ListKeys(ctx context.Context, prefix string) ([]string, error)
	List(ctx context.Context, prefix string) ([]*Model, error)
	TriggerNodeBindingRefresh(ctx context.Context) error
}

ICore is an interface over nodebinding core

func NewCore

func NewCore(repo IRepo) ICore

NewCore returns an instance of Core

type IRepo

type IRepo interface {
	common.IRepo
	List(ctx context.Context, prefix string) ([]common.IModel, error)
}

IRepo interface over database repository

func NewRepo

func NewRepo(registry registry.IRegistry) IRepo

NewRepo returns IRepo

type Model

type Model struct {
	common.BaseModel
	ID                  string `json:"id"`
	NodeID              string `json:"node_id"`
	SubscriptionID      string `json:"subscription_id"`
	SubscriptionVersion string `json:"subscription_version"`
	Partition           int    `json:"partition"`
}

Model for a node

func (*Model) DefunctKey

func (m *Model) DefunctKey() string

DefunctKey returns the key without the partition identifier

func (*Model) Key

func (m *Model) Key() string

Key returns the key for storing in the registry

func (*Model) Prefix

func (m *Model) Prefix() string

Prefix returns the key prefix

type Repo

type Repo struct {
	common.BaseRepo
}

Repo implements various repository methods

func (*Repo) List

func (r *Repo) List(ctx context.Context, prefix string) ([]common.IModel, error)

List returns a slice of NodeBindings matching prefix

Jump to

Keyboard shortcuts

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