provider

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TermKeyHour  = "hourly"
	TermKeyMonth = "monthly"
	TermKeyYear  = "yearly"
)
View Source
const SchedulerMetadataOfferKey = schedulerMetadataPrefix + "offer"

SchedulerMetadataOfferKey is the metadata key used for the offer name.

Variables

View Source
var DefaultSchedulerApp = map[string]map[string]string{
	"testnet": {
		"sapphire": "rofl1qrqw99h0f7az3hwt2cl7yeew3wtz0fxunu7luyfg",
	},
}

DefaultSchedulerApp contains the default scheduler app IDs for each network/paratime.

View Source
var ManifestFileNames = []string{
	"rofl-provider.yaml",
	"rofl-provider.yml",
}

ManifestFileNames are the manifest file names that are tried when loading the manifest.

Functions

func ManifestExists

func ManifestExists() bool

ManifestExists checks whether a manifest file exist. No attempt is made to load, parse or validate any of the found manifest files.

Types

type GPUResource

type GPUResource struct {
	// Model is the optional GPU model.
	Model string `yaml:"model,omitempty" json:"model,omitempty"`
	// Count is the number of GPUs requested.
	Count uint8 `yaml:"count" json:"count"`
}

GPUResource is the offered GPU resource.

func (*GPUResource) Validate

func (g *GPUResource) Validate() error

Validate validates the GPU resource.

type Manifest

type Manifest struct {
	// Name is the optional name of the provider.
	Name string `yaml:"name,omitempty" json:"name,omitempty"`
	// Homepage is the optional homepage URL of the provider.
	Homepage string `yaml:"homepage,omitempty" json:"homepage,omitempty"`
	// Description is the optional description of the provider.
	Description string `yaml:"description,omitempty" json:"description,omitempty"`

	// Network is the identifier of the network to deploy to.
	Network string `yaml:"network" json:"network"`
	// ParaTime is the identifier of the paratime to deploy to.
	ParaTime string `yaml:"paratime" json:"paratime"`
	// Provider is the identifier of the provider account.
	Provider string `yaml:"provider,omitempty" json:"provider,omitempty"`

	// Nodes are the public keys of nodes authorized to act on behalf of provider.
	Nodes []signature.PublicKey `yaml:"nodes" json:"nodes"`
	// ScheduperApp is the authorized scheduper app for this provider.
	SchedulerApp rofl.AppID `yaml:"scheduler_app" json:"scheduler_app"`
	// PaymentAddress is the payment address.
	PaymentAddress string `yaml:"payment_address" json:"payment_address"`
	// Offers is a list of offers available from this provider.
	Offers []*Offer `yaml:"offers,omitempty" json:"offers,omitempty"`
	// Metadata is arbitrary metadata (key-value pairs) assigned by the provider.
	Metadata map[string]string `yaml:"metadata,omitempty" json:"metadata,omitempty"`
	// contains filtered or unexported fields
}

Manifest is the manifest describing a provider.

func LoadManifest

func LoadManifest() (*Manifest, error)

LoadManifest attempts to find and load the ROFL app manifest from a local file.

func (*Manifest) GetMetadata

func (m *Manifest) GetMetadata() map[string]string

GetMetadata derives metadata from the attributes defined in the manifest and combines it with the specified metadata.

func (*Manifest) Save

func (m *Manifest) Save() error

Save serializes the manifest and writes it to the file returned by `SourceFileName`, overwriting any previous manifest.

If no previous source filename is available, a default one is set.

func (*Manifest) SourceFileName

func (m *Manifest) SourceFileName() string

SourceFileName returns the filename of the manifest file from which the manifest was loaded or an empty string in case the filename is not available.

func (*Manifest) Validate

func (m *Manifest) Validate() error

Validate validates the provider manifest.

type Offer

type Offer struct {
	// ID is the unique offer identifier used by the scheduler.
	ID string `yaml:"id" json:"id"`
	// Resources are the offered resources.
	Resources Resources `yaml:"resources" json:"resources"`
	// Payment is the payment for this offer.
	Payment Payment `yaml:"payment" json:"payment"`
	// Capacity is the amount of available instances. Setting this to zero will disallow
	// provisioning of new instances for this offer. Each accepted instance will automatically
	// decrement capacity.
	Capacity uint64 `yaml:"capacity" json:"capacity"`
	// Metadata is arbitrary metadata (key-value pairs) assigned by the provider.
	Metadata map[string]string `yaml:"metadata,omitempty" json:"metadata,omitempty"`
}

Offer is a provider's offer.

func (*Offer) AsDescriptor

func (o *Offer) AsDescriptor(pt *config.ParaTime) (*roflmarket.Offer, error)

AsDescriptor returns the configuration as an on-chain descriptor.

func (*Offer) GetMetadata

func (o *Offer) GetMetadata() map[string]string

GetMetadata derives metadata from the attributes defined in the offer and combines it with the specified metadata.

func (*Offer) Validate

func (o *Offer) Validate() error

Validate validates the offer.

type Payment

type Payment struct {
	Native *struct {
		Denomination string            `yaml:"denomination" json:"denomination"`
		Terms        map[string]string `yaml:"terms" json:"terms"`
	} `yaml:"native,omitempty" json:"native,omitempty"`

	EvmContract *struct {
		Address string `json:"address"`
		Data    string `json:"data"`
	} `yaml:"evm,omitempty" json:"evm,omitempty"`
}

Payment is payment configuration for an offer.

func (*Payment) AsDescriptor

func (p *Payment) AsDescriptor(pt *config.ParaTime) (*roflmarket.Payment, error)

AsDescriptor returns the configuration as an on-chain descriptor.

func (*Payment) Validate

func (p *Payment) Validate() error

Validate validates the payment configuration.

type Resources

type Resources struct {
	// TEE is the type of TEE hardware.
	TEE string `yaml:"tee" json:"tee"`
	// Memory is the amount of memory in megabytes.
	Memory uint64 `yaml:"memory" json:"memory"`
	// CPUCount is the amount of vCPUs.
	CPUCount uint16 `yaml:"cpus" json:"cpus"`
	// Storage is the amount of storage ine megabytes.
	Storage uint64 `yaml:"storage" json:"storage"`
	// GPU is the optional GPU resource.
	GPU *GPUResource `yaml:"gpu,omitempty" json:"gpu,omitempty"`
}

Resources are describe the offered resources.

func (*Resources) AsDescriptor

func (r *Resources) AsDescriptor() *roflmarket.Resources

AsDescriptor returns the configuration as an on-chain descriptor.

func (*Resources) Validate

func (r *Resources) Validate() error

Validate validates the resources.

Jump to

Keyboard shortcuts

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