Documentation ¶
Index ¶
- Constants
- type ByWeightDesc
- type GPUProviderStore
- func (s *GPUProviderStore) CleanupOutdatedProviders()
- func (s *GPUProviderStore) Create(provider *plugins.GPUProvider) error
- func (s *GPUProviderStore) Delete(walletAddress string) error
- func (s *GPUProviderStore) ListAllProviders() []*plugins.GPUProvider
- func (s *GPUProviderStore) Read(walletAddress string) (*plugins.GPUProvider, error)
- func (s *GPUProviderStore) Update(walletAddress string, provider *plugins.GPUProvider) error
- func (s *GPUProviderStore) Upsert(provider *plugins.GPUProvider) error
- type InMemoryTaskStore
- func (store *InMemoryTaskStore) CleanupOutdatedTasks()
- func (store *InMemoryTaskStore) Create(task *TaskOffer)
- func (store *InMemoryTaskStore) Delete(id string) error
- func (store *InMemoryTaskStore) GetAllPendingTasks() []*TaskOffer
- func (store *InMemoryTaskStore) GetPendingTasksByWeights(weights []WalletWeight, walletAddress string) []*TaskOffer
- func (store *InMemoryTaskStore) Read(id string) (*TaskOffer, error)
- func (store *InMemoryTaskStore) Update(task *TaskOffer) error
- type TaskOffer
- type TaskResult
- type TaskStatus
- type WalletWeight
Constants ¶
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 ¶
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 ¶
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 ¶
Custom JSON marshaling for TaskOffer
func (*TaskOffer) UnmarshalJSON ¶
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.