namespace

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(tenant string, namespace *Namespace) error

Register registers a namespace.

func Unregister

func Unregister(tenant, namespace string) error

Unregister unregisters a namespace.

Types

type Command

type Command func(ns *Namespace) error

Command represents the command to control Namespace.

func RemoveDB

func RemoveDB(group, id string) Command

RemoveDB returns a command to remove an existing DB.

func RemoveGroup

func RemoveGroup(group string) Command

RemoveGroup returns a command to remove an existing DB group.

func RemoveNode

func RemoveNode(group, node string) Command

RemoveNode returns a command to remove an existing node from namespace.

func UpdateParameters

func UpdateParameters(parameters config.ParametersMap) Command

func UpdateRule

func UpdateRule(rule *rule.Rule) Command

UpdateRule updates the rule.

func UpdateSlowLogger

func UpdateSlowLogger(path string, cfg *log.Config) Command

func UpdateSlowThreshold

func UpdateSlowThreshold() Command

func UpdateWeight

func UpdateWeight(group, id string, weight proto.Weight) Command

UpdateWeight returns a command to update the weight of DB.

func UpsertDB

func UpsertDB(group string, ds proto.DB) Command

UpsertDB appends a new DB.

type Namespace

type Namespace struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Namespace represents a logical database with all resources.

func List

func List() []*Namespace

List lists all namespace.

func Load

func Load(tenant, namespace string) *Namespace

Load loads a namespace, return nil if no namespace found.

func New

func New(name string, commands ...Command) (*Namespace, error)

New creates a Namespace.

func (*Namespace) Close

func (ns *Namespace) Close() error

Close closes namespace.

func (*Namespace) DB

func (ns *Namespace) DB(ctx context.Context, group string) proto.DB

DB returns a DB, returns nil if nothing selected.

func (*Namespace) DB0

func (ns *Namespace) DB0(ctx context.Context) proto.DB

func (*Namespace) DBGroups

func (ns *Namespace) DBGroups() []string

DBGroups returns the group names of DB.

func (*Namespace) DBMaster

func (ns *Namespace) DBMaster(_ context.Context, group string) proto.DB

DBMaster returns a master DB, returns nil if nothing selected.

func (*Namespace) DBSlave

func (ns *Namespace) DBSlave(_ context.Context, group string) proto.DB

DBSlave returns a slave DB, returns nil if nothing selected.

func (*Namespace) DBs

func (ns *Namespace) DBs(group string) []proto.DB

func (*Namespace) EnqueueCommand

func (ns *Namespace) EnqueueCommand(cmd Command) error

EnqueueCommand enqueues the next command, it will be executed async.

func (*Namespace) Name

func (ns *Namespace) Name() string

Name returns the name of namespace.

func (*Namespace) Parameters

func (ns *Namespace) Parameters() config.ParametersMap

func (*Namespace) Rule

func (ns *Namespace) Rule() *rule.Rule

Rule returns the sharding rule.

func (*Namespace) SlowLogger

func (ns *Namespace) SlowLogger() log.Logger

func (*Namespace) SlowThreshold

func (ns *Namespace) SlowThreshold() time.Duration

func (*Namespace) SysDB

func (ns *Namespace) SysDB() proto.DB

SysDB returns SysDB

Jump to

Keyboard shortcuts

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