store

package
v0.0.0-...-a894687 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathLabel = "dubbo.io/path"
)

Variables

View Source
var ErrorInvalidOffset = errors.New("invalid offset")

Functions

func CtxWithTx

func CtxWithTx(ctx context.Context, tx Transaction) context.Context

func ErrorResourceAlreadyExists

func ErrorResourceAlreadyExists(rt model.ResourceType, name, mesh string) error

func ErrorResourceAssertion

func ErrorResourceAssertion(msg string, rt model.ResourceType, name, mesh string) error

func ErrorResourceConflict

func ErrorResourceConflict(rt model.ResourceType, name, mesh string) error

func ErrorResourceNotFound

func ErrorResourceNotFound(rt model.ResourceType, name, mesh string) error

func InTx

func InTx(ctx context.Context, transactions Transactions, fn func(ctx context.Context) error) error

func IsResourceNotFound

func IsResourceNotFound(err error) bool

Types

type AssertionError

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

AssertionError

func (*AssertionError) Error

func (e *AssertionError) Error() string

func (*AssertionError) Is

func (e *AssertionError) Is(err error) bool

func (*AssertionError) Unwrap

func (e *AssertionError) Unwrap() error

type ClosableResourceStore

type ClosableResourceStore interface {
	ResourceStore
	io.Closer
}

func NewStrictResourceStore

func NewStrictResourceStore(c ResourceStore) ClosableResourceStore

type CreateOptions

type CreateOptions struct {
	Name         string
	Mesh         string
	CreationTime time.Time
	Owner        core_model.Resource
	Labels       map[string]string
}

func NewCreateOptions

func NewCreateOptions(fs ...CreateOptionsFunc) *CreateOptions

type CreateOptionsFunc

type CreateOptionsFunc func(*CreateOptions)

func CreateByApplication

func CreateByApplication(app string) CreateOptionsFunc

func CreateByID

func CreateByID(id string) CreateOptionsFunc

func CreateByKey

func CreateByKey(name, mesh string) CreateOptionsFunc

func CreateByPath

func CreateByPath(path string) CreateOptionsFunc

func CreateByService

func CreateByService(service string) CreateOptionsFunc

func CreateByServiceGroup

func CreateByServiceGroup(serviceGroup string) CreateOptionsFunc

func CreateByServiceVersion

func CreateByServiceVersion(serviceVersion string) CreateOptionsFunc

func CreateWithLabels

func CreateWithLabels(labels map[string]string) CreateOptionsFunc

func CreateWithOwner

func CreateWithOwner(owner core_model.Resource) CreateOptionsFunc

func CreatedAt

func CreatedAt(creationTime time.Time) CreateOptionsFunc

type CustomizableResourceStore

type CustomizableResourceStore interface {
	ResourceStore
	ResourceStore(typ model.ResourceType) ResourceStore
	DefaultResourceStore() ResourceStore
	Customize(typ model.ResourceType, store ResourceStore)
	WrapAll(wrapper ResourceStoreWrapper)
}

func NewCustomizableResourceStore

func NewCustomizableResourceStore(defaultStore ResourceStore) CustomizableResourceStore

type DeleteAllOptions

type DeleteAllOptions struct {
	Mesh string
}

func NewDeleteAllOptions

func NewDeleteAllOptions(fs ...DeleteAllOptionsFunc) *DeleteAllOptions

type DeleteAllOptionsFunc

type DeleteAllOptionsFunc func(*DeleteAllOptions)

func DeleteAllByMesh

func DeleteAllByMesh(mesh string) DeleteAllOptionsFunc

type DeleteOptions

type DeleteOptions struct {
	Name   string
	Mesh   string
	Labels map[string]string
}

func NewDeleteOptions

func NewDeleteOptions(fs ...DeleteOptionsFunc) *DeleteOptions

type DeleteOptionsFunc

type DeleteOptionsFunc func(*DeleteOptions)

func DeleteByApplication

func DeleteByApplication(app string) DeleteOptionsFunc

func DeleteByID

func DeleteByID(id string) DeleteOptionsFunc

func DeleteByKey

func DeleteByKey(name, mesh string) DeleteOptionsFunc

func DeleteByPath

func DeleteByPath(path string) DeleteOptionsFunc

func DeleteByService

func DeleteByService(service string) DeleteOptionsFunc

func DeleteByServiceGroup

func DeleteByServiceGroup(serviceGroup string) DeleteOptionsFunc

func DeleteByServiceVersion

func DeleteByServiceVersion(serviceVersion string) DeleteOptionsFunc

type GetOptions

type GetOptions struct {
	Name       string
	Mesh       string
	Version    string
	Type       string
	Consistent bool
	Labels     map[string]string
}

func NewGetOptions

func NewGetOptions(fs ...GetOptionsFunc) *GetOptions

func (*GetOptions) HashCode

func (g *GetOptions) HashCode() string

func (*GetOptions) Predicate

func (l *GetOptions) Predicate(r core_model.Resource) bool

type GetOptionsFunc

type GetOptionsFunc func(*GetOptions)

func GetByApplication

func GetByApplication(app string) GetOptionsFunc

func GetByID

func GetByID(id string) GetOptionsFunc

func GetByKey

func GetByKey(name, mesh string) GetOptionsFunc

func GetByPath

func GetByPath(path string) GetOptionsFunc

func GetByRevision

func GetByRevision(revision string) GetOptionsFunc

func GetByService

func GetByService(service string) GetOptionsFunc

func GetByServiceGroup

func GetByServiceGroup(serviceGroup string) GetOptionsFunc

func GetByServiceVersion

func GetByServiceVersion(serviceVersion string) GetOptionsFunc

func GetByType

func GetByType(t string) GetOptionsFunc

func GetByVersion

func GetByVersion(version string) GetOptionsFunc

func GetConsistent

func GetConsistent() GetOptionsFunc

GetConsistent forces consistency if storage provides eventual consistency like read replica for Postgres.

type ListFilterFunc

type ListFilterFunc func(rs core_model.Resource) bool

type ListOptions

type ListOptions struct {
	Mesh                string
	Labels              map[string]string
	PageSize            int
	PageOffset          string
	FilterFunc          ListFilterFunc
	NameContains        string
	NameEquals          string
	ApplicationContains string
	Ordered             bool
	ResourceKeys        map[core_model.ResourceKey]struct{}
}

func NewListOptions

func NewListOptions(fs ...ListOptionsFunc) *ListOptions

func (*ListOptions) Filter

func (l *ListOptions) Filter(rs core_model.Resource) bool

Filter returns true if the item passes the filtering criteria

func (*ListOptions) HashCode

func (l *ListOptions) HashCode() string

func (*ListOptions) IsCacheable

func (l *ListOptions) IsCacheable() bool

func (*ListOptions) Predicate

func (l *ListOptions) Predicate(r core_model.Resource) bool

type ListOptionsFunc

type ListOptionsFunc func(*ListOptions)

func ListByApplication

func ListByApplication(app string) ListOptionsFunc

func ListByApplicationContains

func ListByApplicationContains(app string) ListOptionsFunc

func ListByFilterFunc

func ListByFilterFunc(filterFunc ListFilterFunc) ListOptionsFunc

func ListByMesh

func ListByMesh(mesh string) ListOptionsFunc

func ListByNameContains

func ListByNameContains(name string) ListOptionsFunc

func ListByNameEquals

func ListByNameEquals(name string) ListOptionsFunc

func ListByPage

func ListByPage(size int, offset string) ListOptionsFunc

func ListByPath

func ListByPath(path string) ListOptionsFunc

func ListByResourceKeys

func ListByResourceKeys(rk []core_model.ResourceKey) ListOptionsFunc

func ListOrdered

func ListOrdered() ListOptionsFunc

type NoTransactions

type NoTransactions struct{}

func (NoTransactions) Begin

type NoopTransaction

type NoopTransaction struct{}

func (NoopTransaction) Commit

func (NoopTransaction) Rollback

func (n NoopTransaction) Rollback(context.Context) error

type PreconditionError

type PreconditionError struct {
	Reason string
}

func PreconditionFormatError

func PreconditionFormatError(reason string) *PreconditionError

func (*PreconditionError) Error

func (a *PreconditionError) Error() string

func (*PreconditionError) Is

func (a *PreconditionError) Is(err error) bool

type ResourceConflictError

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

func (*ResourceConflictError) Error

func (e *ResourceConflictError) Error() string

func (*ResourceConflictError) Is

func (e *ResourceConflictError) Is(err error) bool

type ResourceStore

func NewPaginationStore

func NewPaginationStore(delegate ResourceStore) ResourceStore

The Pagination Store is handling only the pagination functionality in the List. This is an in-memory operation and offloads this from the persistent stores (k8s, postgres etc.) Two reasons why this is needed: * There is no filtering + pagination on the native K8S database * On Postgres, we keep the object in a column as a string. We would have to use JSON column type and convert it to native SQL queries.

The in-memory filtering has been tested with 10,000 Dataplanes and proved to be fast enough, although not that efficient.

type ResourceStoreWrapper

type ResourceStoreWrapper = func(delegate ResourceStore) ResourceStore

ResourceStoreWrapper is a function that takes a ResourceStore and returns a wrapped ResourceStore. The wrapped ResourceStore can be used to modify or augment the behavior of the original ResourceStore.

type Transaction

type Transaction interface {
	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error
}

func TxFromCtx

func TxFromCtx(ctx context.Context) (Transaction, bool)

type Transactions

type Transactions interface {
	Begin(ctx context.Context) (Transaction, error)
}

Transactions is a producer of transactions if a resource store support transactions. Transactions are never required for consistency in dubbo, because there are ResourceStores that does not support transactions. However, in a couple of cases executing queries in transaction can improve the performance.

In case of Postgres, you may set hooks when retrieve and release connections for the connection pool. In this case, if you create multiple resources, you need to acquire connection and execute hooks for each create. If you create transaction for it, you execute hooks once and you hold the connection.

Transaction is propagated implicitly through Context.

type UpdateOptions

type UpdateOptions struct {
	Name             string
	Mesh             string
	ModificationTime time.Time
	Labels           map[string]string
}

func NewUpdateOptions

func NewUpdateOptions(fs ...UpdateOptionsFunc) *UpdateOptions

type UpdateOptionsFunc

type UpdateOptionsFunc func(*UpdateOptions)

func ModifiedAt

func ModifiedAt(modificationTime time.Time) UpdateOptionsFunc

func UpdateByApplication

func UpdateByApplication(app string) UpdateOptionsFunc

func UpdateByID

func UpdateByID(id string) UpdateOptionsFunc

func UpdateByKey

func UpdateByKey(name, mesh string) UpdateOptionsFunc

func UpdateByService

func UpdateByService(service string) UpdateOptionsFunc

func UpdateByServiceGroup

func UpdateByServiceGroup(serviceGroup string) UpdateOptionsFunc

func UpdateByServiceVersion

func UpdateByServiceVersion(serviceVersion string) UpdateOptionsFunc

func UpdateWithLabels

func UpdateWithLabels(labels map[string]string) UpdateOptionsFunc

func UpdateWithPath

func UpdateWithPath(path string) UpdateOptionsFunc

Jump to

Keyboard shortcuts

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