resourcemanager

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const RedisSetKey = "qubole"

This is the key that will point to the Redis Set. https://redis.io/commands#set

Variables

View Source
var ExecutionNotFoundError = fmt.Errorf("Execution not found")

This error will be returned when a key is not found in the buffer

Functions

func NewRedisClient

func NewRedisClient(ctx context.Context, host string, key string, maxRetries int) (*redis.Client, error)

Types

type AllocationStatus

type AllocationStatus string
const (
	// This is the enum returned when there's an error
	AllocationUndefined AllocationStatus = "ResourceGranted"

	// Go for it
	AllocationStatusGranted AllocationStatus = "ResourceGranted"

	// This means that no resources are available globally.  This is the only rejection message we use right now.
	AllocationStatusExhausted AllocationStatus = "ResourceExhausted"

	// We're not currently using this - but this would indicate that things globally are okay, but that your
	// own namespace is too busy
	AllocationStatusNamespaceQuotaExceeded AllocationStatus = "NamespaceQuotaExceeded"
)

type ExecutionLooksideBuffer

type ExecutionLooksideBuffer interface {
	ConfirmExecution(ctx context.Context, executionKey string, executionValue string) error
	RetrieveExecution(ctx context.Context, executionKey string) (string, error)
}

Remembers an execution key to a value. Specifically for example in the Qubole case, the key will be the same key that's used in the AutoRefreshCache

type NoopResourceManager

type NoopResourceManager struct {
}

func (NoopResourceManager) AllocateResource

func (NoopResourceManager) AllocateResource(ctx context.Context, namespace string, allocationToken string) (
	AllocationStatus, error)

func (NoopResourceManager) ReleaseResource

func (NoopResourceManager) ReleaseResource(ctx context.Context, namespace string, allocationToken string) error

type RedisLookasideBuffer

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

func NewRedisLookasideBuffer

func NewRedisLookasideBuffer(ctx context.Context, client *redis.Client, redisPrefix string, expiry time.Duration) RedisLookasideBuffer

func (RedisLookasideBuffer) ConfirmExecution

func (r RedisLookasideBuffer) ConfirmExecution(ctx context.Context, executionKey string, executionValue string) error

func (RedisLookasideBuffer) RetrieveExecution

func (r RedisLookasideBuffer) RetrieveExecution(ctx context.Context, executionKey string) (string, error)

type RedisResourceManager

type RedisResourceManager struct {
	Metrics RedisResourceManagerMetrics
	// contains filtered or unexported fields
}

func NewRedisResourceManager

func NewRedisResourceManager(ctx context.Context, client *redis.Client, scope promutils.Scope) (*RedisResourceManager, error)

func (RedisResourceManager) AllocateResource

func (r RedisResourceManager) AllocateResource(ctx context.Context, namespace string, allocationToken string) (
	AllocationStatus, error)

func (RedisResourceManager) ReleaseResource

func (r RedisResourceManager) ReleaseResource(ctx context.Context, namespace string, allocationToken string) error

type RedisResourceManagerMetrics

type RedisResourceManagerMetrics struct {
	Scope                promutils.Scope
	RedisSizeCheckTime   promutils.StopWatch
	AllocatedTokensGauge prometheus.Gauge
}

func NewRedisResourceManagerMetrics

func NewRedisResourceManagerMetrics(scope promutils.Scope) RedisResourceManagerMetrics

type ResourceManager

type ResourceManager interface {
	AllocateResource(ctx context.Context, namespace string, allocationToken string) (AllocationStatus, error)
	ReleaseResource(ctx context.Context, namespace string, allocationToken string) error
}

Resource Manager manages a single resource type, and each allocation is of size one

func GetOrCreateResourceManagerFor

func GetOrCreateResourceManagerFor(ctx context.Context, resourceName string) (ResourceManager, error)

Gets or creates a resource manager to the given resource name. This function is thread-safe and calling it with the same resource name will return the same instance of resource manager every time.

func GetResourceManagerByType

func GetResourceManagerByType(ctx context.Context, managerType string, scope promutils.Scope, redisClient *redis.Client) (
	ResourceManager, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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