types

package
v1.0.0-alpha.11 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package types provides the main types of the library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Affinity

type Affinity metaschedulerabi.Affinity

type AllowanceManager

type AllowanceManager interface {
	// Set the allowance for smart-contract interactions.
	SetAllowance(ctx context.Context, amount *big.Int) error

	// ClearAllowance is an alias to SetAllowance 0.
	ClearAllowance(ctx context.Context) error

	// Get the current allowance toward the contract.
	GetAllowance(ctx context.Context) (*big.Int, error)

	// ReduceToAllowance reduces a channel of approval into allowance.
	ReduceToAllowance(
		ctx context.Context,
		approvals <-chan Approval,
	) (<-chan *big.Int, error)
}

AllowanceManager set the allowed quantity of credit for smart-contract interactions.

type CreditManager

type CreditManager interface {
	// Balance fetches the current balance of credits.
	Balance(ctx context.Context) (*big.Int, error)

	// Balance fetches the current balance of credits.
	BalanceOf(ctx context.Context, address common.Address) (*big.Int, error)

	// Transfer tranfers credits from one address to another.
	Transfer(ctx context.Context, to common.Address, amount *big.Int) error

	// ReduceToBalance reduces a channel of transfers into balance.
	ReduceToBalance(
		ctx context.Context,
		transfers <-chan Transfer,
	) (<-chan *big.Int, error)
}

CreditManager handles the credits of the user.

type EventSubscriber

type EventSubscriber interface {
	// Subscribe to metascheduler events.
	SubscribeEvents(
		ctx context.Context,
		opts ...SubscriptionOption,
	) (ethereum.Subscription, error)
}

EventSubscriber watches smart-contract events.

type Job

type Job *metaschedulerabi.Job

type JobFetcher

type JobFetcher interface {
	// Get a job.
	GetJob(ctx context.Context, id [32]byte) (Job, error)
	// Get a iterator of jobs. If there is no job, nil is returned.
	GetJobs(ctx context.Context) (JobLazyIterator, error)
}

JobFetcher fetches jobs.

type JobLazyIterator

type JobLazyIterator interface {
	// Fetches the next job.
	Next(ctx context.Context) (ok bool)
	// Fetches the previous job.
	Prev(ctx context.Context) (ok bool)
	// Get the current job.
	Current() Job
	// Get the current error.
	Error() error
}

JobLazyIterator iterates on a lazy list of jobs.

When calling Next or Prev, a request will be sent to the data source.

type JobScheduler

type JobScheduler interface {
	// Submit a batch script to the batch service and metascheduler.
	SubmitJob(
		ctx context.Context,
		job *sbatch.Job,
		lockedAmount *big.Int,
		jobName [32]byte,
		opts ...SubmitJobOption,
	) ([32]byte, error)
	// Cancel a job.
	CancelJob(ctx context.Context, jobID [32]byte) error
	// TopUp a job.
	TopUpJob(ctx context.Context, jobID [32]byte, amount *big.Int) error
	// Panic a job.
	PanicJob(ctx context.Context, jobID [32]byte, reason string) error
}

JobScheduler schedules and cancels jobs.

type Label

type Label metaschedulerabi.Label

type LogStream

LogStream is a readable stream of logs.

type Logger

type Logger interface {
	// Watch the logs of a job
	WatchLogs(ctx context.Context, jobID [32]byte) (LogStream, error)
}

Logger fetches the logs of a job.

type ProviderDetail

type ProviderDetail struct {
	metaschedulerabi.Provider
	IsWaitingForApproval bool
	IsValidForScheduling bool
	JobCount             uint64
}

type ProviderManager

type ProviderManager interface {
	Approve(ctx context.Context, provider common.Address) error
	Remove(ctx context.Context, provider common.Address) error
	GetProvider(ctx context.Context, address common.Address) (provider ProviderDetail, err error)
	GetProviders(ctx context.Context) (providers []ProviderDetail, err error)
}

ProviderManager manages admin operation of providers

type SubmitJobOption

type SubmitJobOption func(*SubmitJobOptions)

func WithAffinity

func WithAffinity(affinities ...Affinity) SubmitJobOption

func WithUse

func WithUse(labels ...Label) SubmitJobOption

type SubmitJobOptions

type SubmitJobOptions struct {
	Uses       []Label
	Affinities []Affinity
}

type SubscriptionOption

type SubscriptionOption func(*SubscriptionOptions)

func FilterApproval

func FilterApproval(filtered chan<- Approval) SubscriptionOption

func FilterJobTransition

func FilterJobTransition(
	filtered chan<- JobTransition,
) SubscriptionOption

func FilterNewJobRequest

func FilterNewJobRequest(
	filtered chan<- NewJobRequest,
) SubscriptionOption

func FilterTransfer

func FilterTransfer(filtered chan<- Transfer) SubscriptionOption

type SubscriptionOptions

type SubscriptionOptions struct {
	NewJobRequestChan chan<- NewJobRequest
	JobTransitionChan chan<- JobTransition
	TransferChan      chan<- Transfer
	ApprovalChan      chan<- Approval
}

Directories

Path Synopsis
abi

Jump to

Keyboard shortcuts

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