Documentation
¶
Index ¶
- func MarshalObjToStruct(input interface{}) (*structpb.Struct, error)
- func MarshalPbToString(msg proto.Message) (string, error)
- func MarshalPbToStruct(in proto.Message) (out *structpb.Struct, err error)
- func UnmarshalStructToPb(structObj *structpb.Struct, msg proto.Message) error
- type AutoRefreshCache
- type CacheItemdeprecated
- type CacheSyncAction
- type CacheSyncItem
- type RateLimiter
- type Sequencer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalObjToStruct ¶ added in v0.1.1
Marshals obj into a struct. Will use jsonPb if input is a proto message, otherwise, it'll use json marshaler.
func MarshalPbToString ¶ added in v0.1.1
Marshals a proto message using jsonPb marshaler to string.
func MarshalPbToStruct ¶ added in v0.1.1
Marshals a proto message into proto Struct using jsonPb marshaler.
Types ¶
type AutoRefreshCache ¶
type AutoRefreshCache interface { // starts background refresh of items Start(ctx context.Context) // Get item by id if exists else null Get(id string) CacheItem // Get object if exists else create it GetOrCreate(item CacheItem) (CacheItem, error) }
AutoRefreshCache with regular GetOrCreate and Delete along with background asynchronous refresh. Caller provides callbacks for create, refresh and delete item. The cache doesn't provide apis to update items. Deprecated: This utility is deprecated, it has been refactored and moved into `cache` package.
func NewAutoRefreshCache
deprecated
func NewAutoRefreshCache(syncCb CacheSyncItem, syncRateLimiter RateLimiter, resyncPeriod time.Duration, size int, scope promutils.Scope) (AutoRefreshCache, error)
Deprecated: This utility is deprecated, it has been refactored and moved into `cache` package.
type CacheSyncAction ¶ added in v0.1.2
type CacheSyncAction int
Possible actions for the cache to take as a result of running the sync function on any given cache item Deprecated: This utility is deprecated, it has been refactored and moved into `cache` package.
const ( Unchanged CacheSyncAction = iota // The item returned has been updated and should be updated in the cache Update // The item should be removed from the cache Delete )
type CacheSyncItem ¶
type CacheSyncItem func(ctx context.Context, obj CacheItem) ( newItem CacheItem, result CacheSyncAction, err error)
Your implementation of this function for your cache instance is responsible for returning
- The new CacheItem, and
- What action should be taken. The sync function has no insight into your object, and needs to be told explicitly if the new item is different from the old one.
Deprecated: This utility is deprecated, it has been refactored and moved into `cache` package.
type RateLimiter ¶
Interface to use rate limiter
func NewRateLimiter ¶
func NewRateLimiter(rateLimiterName string, tps float64, burst int) RateLimiter
Create a new rate-limiter with the tps and burst values