state

package
v0.0.0-...-3b69c6d Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager interface {
	// Checks if the model in the region of the provider is allowed to be used.
	// If not, returns false and the duration to wait before retrying.
	Allow(ctx context.Context, provider string, region string, model string, interval time.Duration) (bool, time.Duration, error)

	// Disables the model in the region of the provider for a given duration.
	Disable(ctx context.Context, provider string, region string, model string, duration time.Duration) error

	// Saves the cache for a given key with a given duration.
	SaveCache(ctx context.Context, key string, value []byte, duration time.Duration) error

	// Loads the cache for a given key.
	LoadCache(ctx context.Context, key string) ([]byte, error)
}

type MemoryManager

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

func NewMemoryManager

func NewMemoryManager(cacheMaxBytes int64) (*MemoryManager, func())

func (*MemoryManager) Allow

func (m *MemoryManager) Allow(
	ctx context.Context, provider string, region string, model string,

	interval time.Duration,
) (bool, time.Duration, error)

func (*MemoryManager) Disable

func (m *MemoryManager) Disable(
	ctx context.Context, provider string, region string, model string,
	duration time.Duration,
) error

func (*MemoryManager) LoadCache

func (m *MemoryManager) LoadCache(
	ctx context.Context, key string) ([]byte, error)

func (*MemoryManager) SaveCache

func (m *MemoryManager) SaveCache(
	ctx context.Context, key string, value []byte, duration time.Duration,
) error

type ValkeyManager

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

func NewValkeyManager

func NewValkeyManager(client valkey.Client) *ValkeyManager

func (*ValkeyManager) Allow

func (r *ValkeyManager) Allow(ctx context.Context, provider string, region string, model string, interval time.Duration) (bool, time.Duration, error)

func (*ValkeyManager) Disable

func (r *ValkeyManager) Disable(ctx context.Context, provider string, region string, model string, duration time.Duration) error

func (*ValkeyManager) LoadCache

func (r *ValkeyManager) LoadCache(ctx context.Context, key string) ([]byte, error)

func (*ValkeyManager) SaveCache

func (r *ValkeyManager) SaveCache(
	ctx context.Context, key string, value []byte, duration time.Duration,
) error

Jump to

Keyboard shortcuts

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