solver

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const CONTROL_LOOP_INTERVAL = 10 * time.Second

the background "even if we have not heard of an event" loop i.e. things will not wait 10 seconds - the control loop reacts to events in the system - this 10 second background loop is just for in case we miss any events

View Source
const DOWNLOADS_DIR = "downloaded-files"
View Source
const FILES_DIR = "job-files"

Variables

This section is empty.

Functions

func EnsureDealsFilePath

func EnsureDealsFilePath(id string) (string, error)

func EnsureDownloadsFilePath

func EnsureDownloadsFilePath(id string) (string, error)

func GetDealsFilePath

func GetDealsFilePath(id string) string

func GetDownloadsFilePath

func GetDownloadsFilePath(id string) string

func LogSolverEvent

func LogSolverEvent(badge string, ev SolverEvent)

func NewSolverServer

func NewSolverServer(
	options http.ServerOptions,
	controller *SolverController,
	store store.SolverStore,
) (*solverServer, error)

func ServiceLogSolverEvent

func ServiceLogSolverEvent(service system.Service, ev SolverEvent)

Types

type ListOfResourceOffers

type ListOfResourceOffers []data.ResourceOffer

func (ListOfResourceOffers) Len

func (a ListOfResourceOffers) Len() int

func (ListOfResourceOffers) Less

func (a ListOfResourceOffers) Less(i, j int) bool

func (ListOfResourceOffers) Swap

func (a ListOfResourceOffers) Swap(i, j int)

type Solver

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

func NewSolver

func NewSolver(
	options SolverOptions,
	store store.SolverStore,
	web3SDK *web3.Web3SDK,
) (*Solver, error)

func (*Solver) Start

func (solver *Solver) Start(ctx context.Context, cm *system.CleanupManager) chan error

type SolverClient

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

func NewSolverClient

func NewSolverClient(
	options http.ClientOptions,
) (*SolverClient, error)

func (*SolverClient) AddJobOffer

func (client *SolverClient) AddJobOffer(jobOffer data.JobOffer) (data.JobOfferContainer, error)

func (*SolverClient) AddResourceOffer

func (client *SolverClient) AddResourceOffer(resourceOffer data.ResourceOffer) (data.ResourceOfferContainer, error)

func (*SolverClient) AddResult

func (client *SolverClient) AddResult(result data.Result) (data.Result, error)

func (*SolverClient) DownloadResultFiles

func (client *SolverClient) DownloadResultFiles(id string, localPath string) error

func (*SolverClient) GetDeal

func (client *SolverClient) GetDeal(id string) (data.DealContainer, error)

func (*SolverClient) GetDeals

func (client *SolverClient) GetDeals(query store.GetDealsQuery) ([]data.DealContainer, error)

func (*SolverClient) GetDealsWithFilter

func (client *SolverClient) GetDealsWithFilter(query store.GetDealsQuery, filter func(data.DealContainer) bool) ([]data.DealContainer, error)

func (*SolverClient) GetJobOffers

func (client *SolverClient) GetJobOffers(query store.GetJobOffersQuery) ([]data.JobOfferContainer, error)

func (*SolverClient) GetResourceOffers

func (client *SolverClient) GetResourceOffers(query store.GetResourceOffersQuery) ([]data.ResourceOfferContainer, error)

func (*SolverClient) GetResult

func (client *SolverClient) GetResult(id string) (data.Result, error)

func (*SolverClient) Start

func (client *SolverClient) Start(ctx context.Context, cm *system.CleanupManager) error

connect the websocket to the solver server

func (*SolverClient) SubscribeEvents

func (client *SolverClient) SubscribeEvents(handler func(SolverEvent))

func (*SolverClient) UpdateTransactionsJobCreator

func (client *SolverClient) UpdateTransactionsJobCreator(id string, payload data.DealTransactionsJobCreator) (data.DealContainer, error)

func (*SolverClient) UpdateTransactionsMediator

func (client *SolverClient) UpdateTransactionsMediator(id string, payload data.DealTransactionsMediator) (data.DealContainer, error)

func (*SolverClient) UpdateTransactionsResourceProvider

func (client *SolverClient) UpdateTransactionsResourceProvider(id string, payload data.DealTransactionsResourceProvider) (data.DealContainer, error)

func (*SolverClient) UploadResultFiles

func (client *SolverClient) UploadResultFiles(id string, localPath string) (data.Result, error)

type SolverController

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

func NewSolverController

func NewSolverController(
	web3SDK *web3.Web3SDK,
	store store.SolverStore,
	options SolverOptions,
) (*SolverController, error)

func (*SolverController) Start

func (controller *SolverController) Start(ctx context.Context, cm *system.CleanupManager) chan error

type SolverEvent

type SolverEvent struct {
	EventType     SolverEventType              `json:"event_type"`
	JobOffer      *data.JobOfferContainer      `json:"job_offer"`
	ResourceOffer *data.ResourceOfferContainer `json:"resource_offer"`
	Deal          *data.DealContainer          `json:"deal"`
}

type SolverEventType

type SolverEventType string

add an enum for various types of event

const (
	JobOfferAdded                       SolverEventType = "JobOfferAdded"
	ResourceOfferAdded                  SolverEventType = "ResourceOfferAdded"
	DealAdded                           SolverEventType = "DealAdded"
	JobOfferStateUpdated                SolverEventType = "JobOfferStateUpdated"
	ResourceOfferStateUpdated           SolverEventType = "ResourceOfferStateUpdated"
	DealStateUpdated                    SolverEventType = "DealStateUpdated"
	DealMediatorUpdated                 SolverEventType = "DealMediatorUpdated"
	ResourceProviderTransactionsUpdated SolverEventType = "ResourceProviderTransactionsUpdated"
	JobCreatorTransactionsUpdated       SolverEventType = "JobCreatorTransactionsUpdated"
	MediatorTransactionsUpdated         SolverEventType = "MediatorTransactionsUpdated"
)

type SolverOptions

type SolverOptions struct {
	Web3   web3.Web3Options
	Server http.ServerOptions
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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