Documentation ¶
Overview ¶
Package cache is a generated GoMock package.
Index ¶
- Constants
- Variables
- type Cache
- type CallbackFn
- type DomainCache
- type DomainCacheEntries
- type DomainCacheEntry
- func CreateDomainCacheEntry(domainName string) *DomainCacheEntry
- func NewDomainCacheEntryForTest(info *persistence.DomainInfo, config *persistence.DomainConfig, ...) *DomainCacheEntry
- func NewGlobalDomainCacheEntryForTest(info *persistence.DomainInfo, config *persistence.DomainConfig, ...) *DomainCacheEntry
- func NewLocalDomainCacheEntryForTest(info *persistence.DomainInfo, config *persistence.DomainConfig, ...) *DomainCacheEntry
- func (entry *DomainCacheEntry) GetConfig() *persistence.DomainConfig
- func (entry *DomainCacheEntry) GetConfigVersion() int64
- func (entry *DomainCacheEntry) GetDomainNotActiveErr() error
- func (entry *DomainCacheEntry) GetFailoverEndTime() *int64
- func (entry *DomainCacheEntry) GetFailoverNotificationVersion() int64
- func (entry *DomainCacheEntry) GetFailoverVersion() int64
- func (entry *DomainCacheEntry) GetInfo() *persistence.DomainInfo
- func (entry *DomainCacheEntry) GetNotificationVersion() int64
- func (entry *DomainCacheEntry) GetPreviousFailoverVersion() int64
- func (entry *DomainCacheEntry) GetReplicationConfig() *persistence.DomainReplicationConfig
- func (entry *DomainCacheEntry) GetReplicationPolicy() ReplicationPolicy
- func (entry *DomainCacheEntry) GetRetentionDays(workflowID string) int32
- func (entry *DomainCacheEntry) IsDomainActive() bool
- func (entry *DomainCacheEntry) IsDomainPendingActive() bool
- func (entry *DomainCacheEntry) IsGlobalDomain() bool
- func (entry *DomainCacheEntry) IsSampledForLongerRetention(workflowID string) bool
- func (entry *DomainCacheEntry) IsSampledForLongerRetentionEnabled(workflowID string) bool
- type DomainMetricsScopeCache
- type Entry
- type GetCacheItemSizeFunc
- type Iterator
- type MockDomainCache
- func (m *MockDomainCache) EXPECT() *MockDomainCacheMockRecorder
- func (m *MockDomainCache) GetAllDomain() map[string]*DomainCacheEntry
- func (m *MockDomainCache) GetCacheSize() (int64, int64)
- func (m *MockDomainCache) GetDomain(name string) (*DomainCacheEntry, error)
- func (m *MockDomainCache) GetDomainByID(id string) (*DomainCacheEntry, error)
- func (m *MockDomainCache) GetDomainID(name string) (string, error)
- func (m *MockDomainCache) GetDomainName(id string) (string, error)
- func (m *MockDomainCache) RegisterDomainChangeCallback(shard int, initialNotificationVersion int64, prepareCallback PrepareCallbackFn, ...)
- func (m *MockDomainCache) Start()
- func (m *MockDomainCache) Stop()
- func (m *MockDomainCache) UnregisterDomainChangeCallback(shard int)
- type MockDomainCacheMockRecorder
- func (mr *MockDomainCacheMockRecorder) GetAllDomain() *gomock.Call
- func (mr *MockDomainCacheMockRecorder) GetCacheSize() *gomock.Call
- func (mr *MockDomainCacheMockRecorder) GetDomain(name interface{}) *gomock.Call
- func (mr *MockDomainCacheMockRecorder) GetDomainByID(id interface{}) *gomock.Call
- func (mr *MockDomainCacheMockRecorder) GetDomainID(name interface{}) *gomock.Call
- func (mr *MockDomainCacheMockRecorder) GetDomainName(id interface{}) *gomock.Call
- func (mr *MockDomainCacheMockRecorder) RegisterDomainChangeCallback(shard, initialNotificationVersion, prepareCallback, callback interface{}) *gomock.Call
- func (mr *MockDomainCacheMockRecorder) Start() *gomock.Call
- func (mr *MockDomainCacheMockRecorder) Stop() *gomock.Call
- func (mr *MockDomainCacheMockRecorder) UnregisterDomainChangeCallback(shard interface{}) *gomock.Call
- type Options
- type PrepareCallbackFn
- type RemovedFunc
- type ReplicationPolicy
- type SimpleOptions
Constants ¶
const ( // DomainCacheRefreshInterval domain cache refresh interval DomainCacheRefreshInterval = 10 * time.Second // DomainCacheRefreshFailureRetryInterval is the wait time // if refreshment encounters error DomainCacheRefreshFailureRetryInterval = 1 * time.Second )
Variables ¶
var ( // DummyCreateTime is the create time used by all entries in the cache. DummyCreateTime = time.Time{} )
var ( // ErrCacheFull is returned if Put fails due to cache being filled with pinned elements ErrCacheFull = errors.New("Cache capacity is fully occupied with pinned elements") )
var SampleRateKey = "sample_retention_rate"
SampleRateKey is key to specify sample rate
var SampleRetentionKey = "sample_retention_days"
SampleRetentionKey is key to specify sample retention
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Get retrieves an element based on a key, returning nil if the element // does not exist Get(key interface{}) interface{} // Put adds an element to the cache, returning the previous element Put(key interface{}, value interface{}) interface{} // PutIfNotExist puts a value associated with a given key if it does not exist PutIfNotExist(key interface{}, value interface{}) (interface{}, error) // Delete deletes an element in the cache Delete(key interface{}) // Release decrements the ref count of a pinned element. If the ref count // drops to 0, the element can be evicted from the cache. Release(key interface{}) // Iterator returns the iterator of the cache Iterator() Iterator // Size returns the number of entries currently stored in the Cache Size() int }
A Cache is a generalized interface to a cache. See cache.LRU for a specific implementation (bounded cache with LRU eviction)
func NewSimple ¶ added in v0.12.0
func NewSimple(opts *SimpleOptions) Cache
NewSimple creates a new simple cache with given options. Simple cache will never evict entries and it will never reorder the elements. Simple cache also does not have the concept of pinning that LRU cache has. Internally simple cache uses a RWMutex instead of the exclusive Mutex that LRU cache uses. The RWMutex makes simple cache readable by many threads without introducing lock contention.
type CallbackFn ¶ added in v0.3.14
type CallbackFn func(prevDomains []*DomainCacheEntry, nextDomains []*DomainCacheEntry)
CallbackFn is function to be called when the domain cache entries are changed it is guaranteed that PrepareCallbackFn and CallbackFn pair will be both called or non will be called
type DomainCache ¶
type DomainCache interface { common.Daemon RegisterDomainChangeCallback(shard int, initialNotificationVersion int64, prepareCallback PrepareCallbackFn, callback CallbackFn) UnregisterDomainChangeCallback(shard int) GetDomain(name string) (*DomainCacheEntry, error) GetDomainByID(id string) (*DomainCacheEntry, error) GetDomainID(name string) (string, error) GetDomainName(id string) (string, error) GetAllDomain() map[string]*DomainCacheEntry GetCacheSize() (sizeOfCacheByName int64, sizeOfCacheByID int64) }
DomainCache is used the cache domain information and configuration to avoid making too many calls to cassandra. This cache is mainly used by frontend for resolving domain names to domain uuids which are used throughout the system. Each domain entry is kept in the cache for one hour but also has an expiry of 10 seconds. This results in updating the domain entry every 10 seconds but in the case of a cassandra failure we can still keep on serving requests using the stale entry from cache upto an hour
func NewDomainCache ¶
func NewDomainCache( metadataMgr persistence.MetadataManager, clusterMetadata cluster.Metadata, metricsClient metrics.Client, logger log.Logger, ) DomainCache
NewDomainCache creates a new instance of cache for holding onto domain information to reduce the load on persistence
type DomainCacheEntries ¶ added in v0.3.13
type DomainCacheEntries []*DomainCacheEntry
DomainCacheEntries is DomainCacheEntry slice
func (DomainCacheEntries) Len ¶ added in v0.3.13
func (t DomainCacheEntries) Len() int
Len return length
func (DomainCacheEntries) Less ¶ added in v0.3.13
func (t DomainCacheEntries) Less(i, j int) bool
Less implements sort.Interface
func (DomainCacheEntries) Swap ¶ added in v0.3.13
func (t DomainCacheEntries) Swap(i, j int)
Swap implements sort.Interface.
type DomainCacheEntry ¶ added in v0.3.12
DomainCacheEntry contains the info and config for a domain
func CreateDomainCacheEntry ¶ added in v0.3.14
func CreateDomainCacheEntry( domainName string, ) *DomainCacheEntry
CreateDomainCacheEntry create a cache entry with domainName
func NewDomainCacheEntryForTest ¶ added in v0.5.2
func NewDomainCacheEntryForTest( info *persistence.DomainInfo, config *persistence.DomainConfig, isGlobalDomain bool, repConfig *persistence.DomainReplicationConfig, failoverVersion int64, failoverEndtime *int64, clusterMetadata cluster.Metadata, ) *DomainCacheEntry
NewDomainCacheEntryForTest returns an entry with test data
func NewGlobalDomainCacheEntryForTest ¶ added in v0.6.0
func NewGlobalDomainCacheEntryForTest( info *persistence.DomainInfo, config *persistence.DomainConfig, repConfig *persistence.DomainReplicationConfig, failoverVersion int64, clusterMetadata cluster.Metadata, ) *DomainCacheEntry
NewGlobalDomainCacheEntryForTest returns an entry with test data
func NewLocalDomainCacheEntryForTest ¶ added in v0.6.0
func NewLocalDomainCacheEntryForTest( info *persistence.DomainInfo, config *persistence.DomainConfig, targetCluster string, clusterMetadata cluster.Metadata, ) *DomainCacheEntry
NewLocalDomainCacheEntryForTest returns an entry with test data
func (*DomainCacheEntry) GetConfig ¶ added in v0.3.12
func (entry *DomainCacheEntry) GetConfig() *persistence.DomainConfig
GetConfig return the domain config
func (*DomainCacheEntry) GetConfigVersion ¶ added in v0.3.12
func (entry *DomainCacheEntry) GetConfigVersion() int64
GetConfigVersion return the domain config version
func (*DomainCacheEntry) GetDomainNotActiveErr ¶ added in v0.3.12
func (entry *DomainCacheEntry) GetDomainNotActiveErr() error
GetDomainNotActiveErr return err if domain is not active, nil otherwise
func (*DomainCacheEntry) GetFailoverEndTime ¶ added in v0.14.0
func (entry *DomainCacheEntry) GetFailoverEndTime() *int64
GetFailoverEndTime return the failover end time
func (*DomainCacheEntry) GetFailoverNotificationVersion ¶ added in v0.3.13
func (entry *DomainCacheEntry) GetFailoverNotificationVersion() int64
GetFailoverNotificationVersion return the global notification version of when failover happened
func (*DomainCacheEntry) GetFailoverVersion ¶ added in v0.3.12
func (entry *DomainCacheEntry) GetFailoverVersion() int64
GetFailoverVersion return the domain failover version
func (*DomainCacheEntry) GetInfo ¶ added in v0.3.12
func (entry *DomainCacheEntry) GetInfo() *persistence.DomainInfo
GetInfo return the domain info
func (*DomainCacheEntry) GetNotificationVersion ¶ added in v0.3.13
func (entry *DomainCacheEntry) GetNotificationVersion() int64
GetNotificationVersion return the global notification version of when domain changed
func (*DomainCacheEntry) GetPreviousFailoverVersion ¶ added in v0.14.0
func (entry *DomainCacheEntry) GetPreviousFailoverVersion() int64
GetPreviousFailoverVersion return the last domain failover version
func (*DomainCacheEntry) GetReplicationConfig ¶ added in v0.3.12
func (entry *DomainCacheEntry) GetReplicationConfig() *persistence.DomainReplicationConfig
GetReplicationConfig return the domain replication config
func (*DomainCacheEntry) GetReplicationPolicy ¶ added in v0.7.0
func (entry *DomainCacheEntry) GetReplicationPolicy() ReplicationPolicy
GetReplicationPolicy return the derived workflow replication policy
func (*DomainCacheEntry) GetRetentionDays ¶ added in v0.4.0
func (entry *DomainCacheEntry) GetRetentionDays( workflowID string, ) int32
GetRetentionDays returns retention in days for given workflow
func (*DomainCacheEntry) IsDomainActive ¶ added in v0.3.12
func (entry *DomainCacheEntry) IsDomainActive() bool
IsDomainActive return whether the domain is active, i.e. non global domain or global domain which active cluster is the current cluster
func (*DomainCacheEntry) IsDomainPendingActive ¶ added in v0.13.0
func (entry *DomainCacheEntry) IsDomainPendingActive() bool
IsDomainPendingActive returns whether the domain is in pending active state
func (*DomainCacheEntry) IsGlobalDomain ¶ added in v0.3.12
func (entry *DomainCacheEntry) IsGlobalDomain() bool
IsGlobalDomain return whether the domain is a global domain
func (*DomainCacheEntry) IsSampledForLongerRetention ¶ added in v0.4.0
func (entry *DomainCacheEntry) IsSampledForLongerRetention( workflowID string, ) bool
IsSampledForLongerRetention return should given workflow been sampled or not
func (*DomainCacheEntry) IsSampledForLongerRetentionEnabled ¶ added in v0.4.0
func (entry *DomainCacheEntry) IsSampledForLongerRetentionEnabled( workflowID string, ) bool
IsSampledForLongerRetentionEnabled return whether sample for longer retention is enabled or not
type DomainMetricsScopeCache ¶ added in v0.14.0
type DomainMetricsScopeCache interface { // Get retrieves metrics scope for a domainID and scopeIdx Get(domainID string, scopeIdx int) (metrics.Scope, bool) // Put adds metrics scope for a domainID and scopeIdx Put(domainID string, scopeIdx int, metricsScope metrics.Scope) }
DomainMetricsScopeCache represents a interface for mapping domainID and scopeIdx to metricsScope
func NewDomainMetricsScopeCache ¶ added in v0.14.0
func NewDomainMetricsScopeCache() DomainMetricsScopeCache
NewDomainMetricsScopeCache constructs a new domainMetricsScopeCache
type Entry ¶ added in v0.3.5
type Entry interface { // Key represents the key Key() interface{} // Value represents the value Value() interface{} // CreateTime represents the time when the entry is created CreateTime() time.Time }
Entry represents a key-value entry within the map
type GetCacheItemSizeFunc ¶ added in v0.14.0
type GetCacheItemSizeFunc func(interface{}) uint64
GetCacheItemSizeFunc returns the cache item size in bytes
type Iterator ¶ added in v0.3.5
type Iterator interface { // Close closes the iterator // and releases any allocated resources Close() // HasNext return true if there is more items to be returned HasNext() bool // Next return the next item Next() Entry }
Iterator represents the interface for cache iterators
type MockDomainCache ¶ added in v0.11.0
type MockDomainCache struct {
// contains filtered or unexported fields
}
MockDomainCache is a mock of DomainCache interface
func NewMockDomainCache ¶ added in v0.11.0
func NewMockDomainCache(ctrl *gomock.Controller) *MockDomainCache
NewMockDomainCache creates a new mock instance
func (*MockDomainCache) EXPECT ¶ added in v0.11.0
func (m *MockDomainCache) EXPECT() *MockDomainCacheMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockDomainCache) GetAllDomain ¶ added in v0.11.0
func (m *MockDomainCache) GetAllDomain() map[string]*DomainCacheEntry
GetAllDomain mocks base method
func (*MockDomainCache) GetCacheSize ¶ added in v0.11.0
func (m *MockDomainCache) GetCacheSize() (int64, int64)
GetCacheSize mocks base method
func (*MockDomainCache) GetDomain ¶ added in v0.11.0
func (m *MockDomainCache) GetDomain(name string) (*DomainCacheEntry, error)
GetDomain mocks base method
func (*MockDomainCache) GetDomainByID ¶ added in v0.11.0
func (m *MockDomainCache) GetDomainByID(id string) (*DomainCacheEntry, error)
GetDomainByID mocks base method
func (*MockDomainCache) GetDomainID ¶ added in v0.11.0
func (m *MockDomainCache) GetDomainID(name string) (string, error)
GetDomainID mocks base method
func (*MockDomainCache) GetDomainName ¶ added in v0.11.0
func (m *MockDomainCache) GetDomainName(id string) (string, error)
GetDomainName mocks base method
func (*MockDomainCache) RegisterDomainChangeCallback ¶ added in v0.11.0
func (m *MockDomainCache) RegisterDomainChangeCallback(shard int, initialNotificationVersion int64, prepareCallback PrepareCallbackFn, callback CallbackFn)
RegisterDomainChangeCallback mocks base method
func (*MockDomainCache) Start ¶ added in v0.11.0
func (m *MockDomainCache) Start()
Start mocks base method
func (*MockDomainCache) Stop ¶ added in v0.11.0
func (m *MockDomainCache) Stop()
Stop mocks base method
func (*MockDomainCache) UnregisterDomainChangeCallback ¶ added in v0.11.0
func (m *MockDomainCache) UnregisterDomainChangeCallback(shard int)
UnregisterDomainChangeCallback mocks base method
type MockDomainCacheMockRecorder ¶ added in v0.11.0
type MockDomainCacheMockRecorder struct {
// contains filtered or unexported fields
}
MockDomainCacheMockRecorder is the mock recorder for MockDomainCache
func (*MockDomainCacheMockRecorder) GetAllDomain ¶ added in v0.11.0
func (mr *MockDomainCacheMockRecorder) GetAllDomain() *gomock.Call
GetAllDomain indicates an expected call of GetAllDomain
func (*MockDomainCacheMockRecorder) GetCacheSize ¶ added in v0.11.0
func (mr *MockDomainCacheMockRecorder) GetCacheSize() *gomock.Call
GetCacheSize indicates an expected call of GetCacheSize
func (*MockDomainCacheMockRecorder) GetDomain ¶ added in v0.11.0
func (mr *MockDomainCacheMockRecorder) GetDomain(name interface{}) *gomock.Call
GetDomain indicates an expected call of GetDomain
func (*MockDomainCacheMockRecorder) GetDomainByID ¶ added in v0.11.0
func (mr *MockDomainCacheMockRecorder) GetDomainByID(id interface{}) *gomock.Call
GetDomainByID indicates an expected call of GetDomainByID
func (*MockDomainCacheMockRecorder) GetDomainID ¶ added in v0.11.0
func (mr *MockDomainCacheMockRecorder) GetDomainID(name interface{}) *gomock.Call
GetDomainID indicates an expected call of GetDomainID
func (*MockDomainCacheMockRecorder) GetDomainName ¶ added in v0.11.0
func (mr *MockDomainCacheMockRecorder) GetDomainName(id interface{}) *gomock.Call
GetDomainName indicates an expected call of GetDomainName
func (*MockDomainCacheMockRecorder) RegisterDomainChangeCallback ¶ added in v0.11.0
func (mr *MockDomainCacheMockRecorder) RegisterDomainChangeCallback(shard, initialNotificationVersion, prepareCallback, callback interface{}) *gomock.Call
RegisterDomainChangeCallback indicates an expected call of RegisterDomainChangeCallback
func (*MockDomainCacheMockRecorder) Start ¶ added in v0.11.0
func (mr *MockDomainCacheMockRecorder) Start() *gomock.Call
Start indicates an expected call of Start
func (*MockDomainCacheMockRecorder) Stop ¶ added in v0.11.0
func (mr *MockDomainCacheMockRecorder) Stop() *gomock.Call
Stop indicates an expected call of Stop
func (*MockDomainCacheMockRecorder) UnregisterDomainChangeCallback ¶ added in v0.11.0
func (mr *MockDomainCacheMockRecorder) UnregisterDomainChangeCallback(shard interface{}) *gomock.Call
UnregisterDomainChangeCallback indicates an expected call of UnregisterDomainChangeCallback
type Options ¶
type Options struct { // TTL controls the time-to-live for a given cache entry. Cache entries that // are older than the TTL will not be returned. TTL time.Duration // InitialCapacity controls the initial capacity of the cache InitialCapacity int // Pin prevents in-use objects from getting evicted. Pin bool // RemovedFunc is an optional function called when an element // is scheduled for deletion RemovedFunc RemovedFunc // MaxCount controls the max capacity of the cache // It is required option if MaxSize is not provided MaxCount int // GetCacheItemSizeFunc is a function called upon adding the item to update the cache size. // It returns 0 by default, assuming the cache is just count based // It is required option if MaxCount is not provided GetCacheItemSizeFunc GetCacheItemSizeFunc // MaxSize is an optional and must be set along with GetCacheItemSizeFunc // to control the max size in bytes of the cache // It is required option if MaxCount is not provided MaxSize uint64 }
Options control the behavior of the cache
type PrepareCallbackFn ¶ added in v0.5.0
type PrepareCallbackFn func()
PrepareCallbackFn is function to be called before CallbackFn is called, it is guaranteed that PrepareCallbackFn and CallbackFn pair will be both called or non will be called
type RemovedFunc ¶
type RemovedFunc func(interface{})
RemovedFunc is a type for notifying applications when an item is scheduled for removal from the Cache. If f is a function with the appropriate signature and i is the interface{} scheduled for deletion, Cache calls go f(i)
type ReplicationPolicy ¶ added in v0.7.0
type ReplicationPolicy int
ReplicationPolicy is the domain's replication policy, derived from domain's replication config
const ( // ReplicationPolicyOneCluster indicate that workflows does not need to be replicated // applicable to local domain & global domain with one cluster ReplicationPolicyOneCluster ReplicationPolicy = 0 // ReplicationPolicyMultiCluster indicate that workflows need to be replicated ReplicationPolicyMultiCluster ReplicationPolicy = 1 )
type SimpleOptions ¶ added in v0.12.0
type SimpleOptions struct { // InitialCapacity controls the initial capacity of the cache InitialCapacity int // RemovedFunc is an optional function called when an element // is scheduled for deletion RemovedFunc RemovedFunc }
SimpleOptions provides options that can be used to configure SimpleCache