store

package
v0.0.0-...-84f0667 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskTTL = 5 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ByWeightDesc

type ByWeightDesc []WalletWeight

ByWeightDesc implements sort.Interface to sort by Weight in descending order

func (ByWeightDesc) Len

func (w ByWeightDesc) Len() int

Len returns the number of elements in the collection

func (ByWeightDesc) Less

func (w ByWeightDesc) Less(i, j int) bool

Less compares two elements to determine their order. In this case, descending by Weight

func (ByWeightDesc) Swap

func (w ByWeightDesc) Swap(i, j int)

Swap swaps the positions of two elements

type GPUProviderStore

type GPUProviderStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewGPUProviderStore

func NewGPUProviderStore() *GPUProviderStore

func (*GPUProviderStore) CleanupOutdatedProviders

func (s *GPUProviderStore) CleanupOutdatedProviders()

func (*GPUProviderStore) Create

func (s *GPUProviderStore) Create(provider *plugins.GPUProvider) error

Create adds a new GPUProvider to the store

func (*GPUProviderStore) Delete

func (s *GPUProviderStore) Delete(walletAddress string) error

Delete removes a GPUProvider from the store

func (*GPUProviderStore) ListAllProviders

func (s *GPUProviderStore) ListAllProviders() []*plugins.GPUProvider

func (*GPUProviderStore) Read

func (s *GPUProviderStore) Read(walletAddress string) (*plugins.GPUProvider, error)

Read retrieves a GPUProvider by walletAddress

func (*GPUProviderStore) Update

func (s *GPUProviderStore) Update(walletAddress string, provider *plugins.GPUProvider) error

Update modifies an existing GPUProvider in the store

func (*GPUProviderStore) Upsert

func (s *GPUProviderStore) Upsert(provider *plugins.GPUProvider) error

type InMemoryTaskStore

type InMemoryTaskStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewInMemoryTaskStore

func NewInMemoryTaskStore() *InMemoryTaskStore

func (*InMemoryTaskStore) CleanupOutdatedTasks

func (store *InMemoryTaskStore) CleanupOutdatedTasks()

CleanupOutdatedTasks removes tasks that are older than the TTL.

func (*InMemoryTaskStore) Create

func (store *InMemoryTaskStore) Create(task *TaskOffer)

Create adds a new task to the store

func (*InMemoryTaskStore) Delete

func (store *InMemoryTaskStore) Delete(id string) error

Delete removes a task from the store

func (*InMemoryTaskStore) GetAllPendingTasks

func (store *InMemoryTaskStore) GetAllPendingTasks() []*TaskOffer

GetAllPendingTasks returns all tasks that have a status of Pending.

func (*InMemoryTaskStore) GetPendingTasksByWeights

func (store *InMemoryTaskStore) GetPendingTasksByWeights(weights []WalletWeight, walletAddress string) []*TaskOffer

func (*InMemoryTaskStore) Read

func (store *InMemoryTaskStore) Read(id string) (*TaskOffer, error)

Read retrieves a task by id

func (*InMemoryTaskStore) Update

func (store *InMemoryTaskStore) Update(task *TaskOffer) error

Update modifies an existing task in the store

type TaskOffer

type TaskOffer struct {
	Id                string               `json:"id"`
	Status            TaskStatus           `json:"status"` // Custom marshaling to be implemented
	CoinSymbol        plugins.CoinSymbol   `json:"coinSymbol"`
	MaxOfferPrice     *big.Int             `json:"maxOfferPrice"` // Custom marshaling to be implemented
	CreatedAt         time.Time            `json:"createdAt"`
	ResultPayloadChan chan json.RawMessage `json:"-"` // Omitted from JSON

	Payload                       json.RawMessage `json:"payload"`
	AssignedWorkerWalletAddresses []string
}

func (TaskOffer) MarshalJSON

func (t TaskOffer) MarshalJSON() ([]byte, error)

Custom JSON marshaling for TaskOffer

func (*TaskOffer) UnmarshalJSON

func (t *TaskOffer) UnmarshalJSON(data []byte) error

Custom JSON unmarshaling for TaskOffer

type TaskResult

type TaskResult struct {
	Id      string          `json:"id"`
	Payload json.RawMessage `json:"payload"`
	Status  TaskStatus      `json:"status"`
}

func (TaskResult) MarshalJSON

func (result TaskResult) MarshalJSON() ([]byte, error)

func (*TaskResult) UnmarshalJSON

func (result *TaskResult) UnmarshalJSON(data []byte) error

type TaskStatus

type TaskStatus int

TaskStatus represents the status of an image generation task.

const (
	// Define task statuses using iota for auto-incrementing.
	Unknown TaskStatus = iota
	Pending
	InProgress
	Completed
	Failed
)

func TaskStatusFromString

func TaskStatusFromString(s string) (TaskStatus, error)

TaskStatusFromString converts a string to a TaskStatus.

func (TaskStatus) String

func (ts TaskStatus) String() string

String returns the string representation of the TaskStatus.

type WalletWeight

type WalletWeight struct {
	WalletAddress string
	Weight        *big.Int
}

Jump to

Keyboard shortcuts

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