cache

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxFindConsumer         ContextKey = "_consumer"
	CtxFindProvider         ContextKey = "_provider"
	CtxFindProviderInstance ContextKey = "_provider_instance"
	CtxFindTags             ContextKey = "_tags"
	CtxFindRequestRev       ContextKey = "_rev"

	Find = "_find"
	Dep  = "_dep"

	DefaultCacheMaxSize = 10000
)

Variables

View Source
var DependencyRule = &DependencyRuleCache{
	Tree: cache.NewTree(cache.Configure().
		WithMaxSize(DefaultCacheMaxSize))}
View Source
var FindInstances = &FindInstancesCache{
	Tree: cache.NewTree(cache.Configure().
		WithTTL(2 * time.Minute).
		WithMaxSize(DefaultCacheMaxSize))}

Functions

This section is empty.

Types

type AccessibleFilter

type AccessibleFilter struct {
}

func (*AccessibleFilter) Init

func (f *AccessibleFilter) Init(ctx context.Context, parent *cache.Node) (node *cache.Node, err error)

func (*AccessibleFilter) Name

func (f *AccessibleFilter) Name(ctx context.Context, _ *cache.Node) string

type ConsistencyFilter

type ConsistencyFilter struct {
	InstancesFilter
}

ConsistencyFilter improves consistency. Scenario: cache maybe different between several service-centers.

func (*ConsistencyFilter) Init

func (f *ConsistencyFilter) Init(ctx context.Context, parent *cache.Node) (node *cache.Node, err error)

Init generates cache. We think cache inconsistency happens and correction is needed only when the revision in the request is not empty and different from the revision of parent cache. To correct inconsistency, RevisionFilter skips cache and get data from the backend directly to response. It's impossible to guarantee consistency if the backend is not creditable, thus in this condition RevisionFilter uses cache only.

func (*ConsistencyFilter) Name

func (f *ConsistencyFilter) Name(ctx context.Context, parent *cache.Node) string

type ConsumerFilter

type ConsumerFilter struct {
}

func (*ConsumerFilter) Init

func (f *ConsumerFilter) Init(ctx context.Context, parent *cache.Node) (node *cache.Node, err error)

func (*ConsumerFilter) Name

func (f *ConsumerFilter) Name(ctx context.Context, _ *cache.Node) string

type ContextKey

type ContextKey string

type DependencyRuleCache

type DependencyRuleCache struct {
	*cache.Tree
}

func (*DependencyRuleCache) ExistVersionRule

func (f *DependencyRuleCache) ExistVersionRule(ctx context.Context, consumerID string, provider *pb.MicroServiceKey) bool

func (*DependencyRuleCache) Remove

func (f *DependencyRuleCache) Remove(provider *pb.MicroServiceKey)

type DependencyRuleItem

type DependencyRuleItem struct {
	VersionRule string
}

type FindInstancesCache

type FindInstancesCache struct {
	*cache.Tree
}

func (*FindInstancesCache) Get

func (f *FindInstancesCache) Get(ctx context.Context, consumer *pb.MicroService, provider *pb.MicroServiceKey,
	tags []string, rev string) (*VersionRuleCacheItem, error)

func (*FindInstancesCache) GetWithProviderID

func (f *FindInstancesCache) GetWithProviderID(ctx context.Context, consumer *pb.MicroService, provider *pb.MicroServiceKey,
	instanceKey *pb.HeartbeatSetElement, tags []string, rev string) (*VersionRuleCacheItem, error)

func (*FindInstancesCache) Remove

func (f *FindInstancesCache) Remove(provider *pb.MicroServiceKey)

type InstancesFilter

type InstancesFilter struct {
}

func (*InstancesFilter) BatchFindInstances

func (f *InstancesFilter) BatchFindInstances(ctx context.Context, domainProject string, serviceIDs []string) (instances []*pb.MicroServiceInstance, rev string, err error)

func (*InstancesFilter) Find

func (f *InstancesFilter) Find(ctx context.Context, parent *cache.Node) (
	instances []*pb.MicroServiceInstance, rev string, err error)

func (*InstancesFilter) FindInstances

func (f *InstancesFilter) FindInstances(ctx context.Context, domainProject string, instanceKey *pb.HeartbeatSetElement) (instances []*pb.MicroServiceInstance, rev string, err error)

func (*InstancesFilter) Init

func (f *InstancesFilter) Init(ctx context.Context, parent *cache.Node) (node *cache.Node, err error)

func (*InstancesFilter) Name

func (f *InstancesFilter) Name(ctx context.Context, _ *cache.Node) string

type ServiceFilter

type ServiceFilter struct {
}

func (*ServiceFilter) Init

func (f *ServiceFilter) Init(ctx context.Context, parent *cache.Node) (node *cache.Node, err error)

func (*ServiceFilter) Name

func (f *ServiceFilter) Name(ctx context.Context, _ *cache.Node) string

type TagsFilter

type TagsFilter struct {
}

func (*TagsFilter) Init

func (f *TagsFilter) Init(ctx context.Context, parent *cache.Node) (node *cache.Node, err error)

func (*TagsFilter) Name

func (f *TagsFilter) Name(ctx context.Context, _ *cache.Node) string

type VersionRuleCacheItem

type VersionRuleCacheItem struct {
	ServiceIds []string
	Instances  []*pb.MicroServiceInstance
	Rev        string
	// contains filtered or unexported fields
}

func (*VersionRuleCacheItem) Broken

func (vi *VersionRuleCacheItem) Broken()

func (*VersionRuleCacheItem) BrokenWait

func (vi *VersionRuleCacheItem) BrokenWait() bool

func (*VersionRuleCacheItem) InitBrokenQueue

func (vi *VersionRuleCacheItem) InitBrokenQueue()

type VersionRuleFilter

type VersionRuleFilter struct {
}

func (*VersionRuleFilter) Init

func (f *VersionRuleFilter) Init(ctx context.Context, parent *cache.Node) (node *cache.Node, err error)

func (*VersionRuleFilter) Name

func (f *VersionRuleFilter) Name(ctx context.Context, _ *cache.Node) string

Jump to

Keyboard shortcuts

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