Documentation ¶
Index ¶
- Constants
- func ConvertBytesToGB(bytes float64) float64
- func ConvertGBToBytes(gb float64) float64
- func ConvertHzToGHz(hz float64) float64
- func ConvertMibToBytes(mib float64) float64
- func ConvertNumericToFloat64(n any) (float64, bool)
- func ConvertTypedSliceToUntypedSlice(typedSlice interface{}) []interface{}
- func IsSameShallowType(a, b interface{}) bool
- func IsStrictlyContained(leftSlice, rightSlice []interface{}) bool
- func IsStrictlyContainedInt(leftSlice, rightSlice []int) bool
- func NewHealthCheck(mf HealthCheckManifest, fn func(HealthCheckManifest) error) (func() error, error)
- func SliceContainsOneValue(slice []Comparison, value Comparison) bool
- type Account
- type BaseDBModel
- type Behavior
- type BootSource
- type CPU
- type Calculable
- type CommittedResources
- type Comparable
- type Comparator
- type Comparison
- type ComplexComparison
- type Config
- type Connectivity
- type Decryptor
- type DeviceResourceChange
- type DeviceResourceConfig
- type DeviceStatusChange
- type Disk
- type Drives
- type EncryptionType
- type Encryptor
- type ExecutionListItem
- type ExecutionRequest
- type ExecutionResult
- type ExecutionStatus
- type Executor
- type ExecutorType
- type Executors
- type FreeResources
- type GPU
- type GPUConnector
- type GPUManager
- type GPUVendor
- type GPUs
- func (gpus GPUs) Add(other GPUs) error
- func (gpus GPUs) Compare(other GPUs) (Comparison, error)
- func (gpus GPUs) Copy() GPUs
- func (gpus GPUs) Equal(other GPUs) bool
- func (gpus GPUs) GetWithIndex(index int) (GPU, error)
- func (gpus GPUs) MaxFreeVRAMGPU() (GPU, error)
- func (gpus GPUs) Subtract(other GPUs) error
- type GeoIPLocator
- type HardwareCapability
- type HardwareManager
- type HealthCheckManifest
- type HealthCheckResponse
- type JobType
- type JobTypes
- type KYC
- type KYCs
- type Libp2pConfig
- type Libraries
- type Library
- type Localities
- type Locality
- type LogStreamRequest
- type MMDSConfig
- type MMDSMetadata
- type MMDSMsg
- type MachineConfig
- type MachineResources
- type MessageEnvelope
- type MessageInfo
- type MessageType
- type NetConfig
- type NetworkConfig
- type NetworkInfo
- type NetworkInterfaces
- type NetworkSpec
- type NetworkStats
- type NetworkType
- type NewDeviceOnboarded
- type NewService
- type NtxPayment
- type OnboardedResources
- type OnboardingConfig
- type OnboardingManager
- type PingResult
- type PortsToBind
- type Preference
- type PreferenceString
- type PriceInformation
- type PricesInformation
- type RAM
- type RequestTracker
- type ResourceAllocation
- type ResourceManager
- type Resources
- type ServiceCall
- type ServiceRemove
- type ServiceStatus
- type SpecConfig
- type StorageVolume
- type StorageVolumeExecutor
- type TimeInformation
Constants ¶
const ( StorageVolumeTypeBind = "bind" StorageProviderS3 = "s3" StorageProviderIPFS = "ipfs" )
const (
NetP2P = "p2p"
)
Variables ¶
This section is empty.
Functions ¶
func ConvertBytesToGB ¶
ConvertBytesToGB converts bytes to gigabytes
func ConvertGBToBytes ¶
ConvertGBToBytes converts gigabytes to bytes
func ConvertHzToGHz ¶
ConvertHzToGHz converts hertz to gigahertz
func ConvertMibToBytes ¶
ConvertMibToBytes converts mebibytes to bytes
func ConvertNumericToFloat64 ¶
func ConvertTypedSliceToUntypedSlice ¶
func ConvertTypedSliceToUntypedSlice(typedSlice interface{}) []interface{}
func IsSameShallowType ¶
func IsSameShallowType(a, b interface{}) bool
func IsStrictlyContained ¶
func IsStrictlyContained(leftSlice, rightSlice []interface{}) bool
IsStrictlyContained checks if all elements of rightSlice are contained in leftSlice
func IsStrictlyContainedInt ¶
IsStrictlyContainedInt checks if all elements of rightSlice are contained in leftSlice
func NewHealthCheck ¶
func NewHealthCheck(mf HealthCheckManifest, fn func(HealthCheckManifest) error) (func() error, error)
func SliceContainsOneValue ¶
func SliceContainsOneValue(slice []Comparison, value Comparison) bool
Types ¶
type Account ¶
type Account struct { Address string `json:"address,omitempty"` PrivateKey string `json:"private_key,omitempty"` Mnemonic string `json:"mnemonic,omitempty"` }
Account represents a blockchain account with an address, private key, and mnemonic.
type BaseDBModel ¶
type BaseDBModel struct { ID string `gorm:"type:uuid"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` }
BaseDBModel is a base model for all entities. It'll be mainly used for database records.
func (*BaseDBModel) BeforeCreate ¶
func (m *BaseDBModel) BeforeCreate(_ *gorm.DB) error
BeforeCreate sets the ID and CreatedAt fields before creating a new entity. This is a GORM hook and should not be called directly. We can move this to generic repository create methods.
func (*BaseDBModel) BeforeUpdate ¶
func (m *BaseDBModel) BeforeUpdate(_ *gorm.DB) error
BeforeUpdate sets the UpdatedAt field before updating an entity. This is a GORM hook and should not be called directly. We can move this to generic repository create methods.
type BootSource ¶
type CPU ¶
type CPU struct { // ClockSpeed represents the CPU clock speed in Hz ClockSpeed float64 `json:"clock_speed" description:"CPU clock speed in Hz"` // Cores represents the number of physical CPU cores Cores float32 `json:"cores" description:"Number of physical CPU cores"` // TODO: capture the below fields if required // Model represents the CPU model, e.g., "Intel Core i7-9700K", "AMD Ryzen 9 5900X" Model string `json:"model,omitempty" description:"CPU model, e.g., Intel Core i7-9700K, AMD Ryzen 9 5900X"` // Vendor represents the CPU manufacturer, e.g., "Intel", "AMD" Vendor string `json:"vendor,omitempty" description:"CPU manufacturer, e.g., Intel, AMD"` // Threads represents the number of logical CPU threads (including hyperthreading) Threads int `json:"threads,omitempty" description:"Number of logical CPU threads (including hyperthreading)"` // Architecture represents the CPU architecture, e.g., "x86", "x86_64", "arm64" Architecture string `json:"architecture,omitempty" description:"CPU architecture, e.g., x86, x86_64, arm64"` // Cache size in bytes CacheSize uint64 `json:"cache_size,omitempty" description:"CPU cache size in bytes"` }
CPU represents the CPU information
func (*CPU) ClockSpeedInGHz ¶
ClockSpeedInGHz returns the clock speed in GHz
func (*CPU) Compare ¶
func (c *CPU) Compare(other CPU) (Comparison, error)
Compare compares the CPU with the other CPU
func (*CPU) ComputeInGHz ¶
ComputeInGHz returns the total compute power of the CPU in GHz
type Calculable ¶
type CommittedResources ¶
type CommittedResources struct { BaseDBModel Resources AllocationID string `json:"allocationID"` }
CommittedResources represents the committed resources of the machine
type Comparable ¶
type Comparable[T any] interface { Compare(other T) (Comparison, error) }
Comparable public Comparable interface to be enforced on types that can be compared
type Comparator ¶
type Comparator func(l, r interface{}, preference ...Preference) Comparison
type Comparison ¶
type Comparison string
Comparison is a type for comparison results
const ( // Worse means left object is 'worse' than right object Worse Comparison = "Worse" // Better means left object is 'better' than right object Better Comparison = "Better" // Equal means objects on the left and right are 'equally good' Equal Comparison = "Equal" // None means comparison could not be performed None Comparison = "None" )
func LiteralComparator ¶
func LiteralComparator[T ~string](l, r T, _ ...Preference) Comparison
func NumericComparator ¶
func NumericComparator[T float64 | float32 | int | int32 | int64 | uint64](l, r T, _ ...Preference) Comparison
func (Comparison) And ¶
func (c Comparison) And(cmp Comparison) Comparison
And returns the result of AND operation of two Comparison values it respects the following table of truth: | AND | Better | Worse | Equal | None | | ------ | ------ |--------|--------|--------| | Better | Better | Worse | Better | None | | Worse | Worse | Worse | Worse | None | | Equal | Better | Worse | Equal | None | | None | None | None | None | None |
type ComplexComparison ¶
type ComplexComparison map[string]Comparison
ComplexComparison is a map of string to Comparison
func ComplexCompare ¶
func ComplexCompare(l, r interface{}) ComplexComparison
ComplexCompare helper function to return a complex comparison of two complex types this uses reflection, could become a performance bottleneck with generics, we wouldn't need this function and could use the ComplexCompare method directly
func (*ComplexComparison) Result ¶
func (c *ComplexComparison) Result() Comparison
Result returns the result of AND operation of all Comparison values in the ComplexComparison
type Config ¶
type Config interface {
GetNetworkConfig() *SpecConfig
}
type Connectivity ¶
type Connectivity struct { Ports []int `json:"ports" description:"Ports that need to be open for the job to run"` VPN bool `json:"vpn" description:"Whether VPN is required"` }
Connectivity represents the network configuration
func (*Connectivity) Add ¶
func (c *Connectivity) Add(other Connectivity) error
func (*Connectivity) Compare ¶
func (c *Connectivity) Compare(other Connectivity) (Comparison, error)
func (*Connectivity) Subtract ¶
func (c *Connectivity) Subtract(other Connectivity) error
type Decryptor ¶
Decryptor (DRAFT)
Warning: this is just a draft. And it might be moved to an Encryption package
TODO: it must support decryption of files/directories, otherwise we have to create another interface for the usecase
type DeviceResourceChange ¶
type DeviceResourceChange struct { PeerID string ChangedAttributeAndValue struct { CPU float32 RAM float32 Network float32 DedicatedTime float32 } Timestamp float32 }
DeviceResourceChange defines the schema of the data to be sent to stats db when a device resource gets changed
type DeviceResourceConfig ¶
type DeviceResourceConfig struct { PeerID string ChangedAttributeAndValue struct { CPU float32 RAM float32 Network float32 DedicatedTime float32 } Timestamp float32 }
DeviceResourceConfig defines the schema of the data to be sent to stats db when a device resource config gets changed
type DeviceStatusChange ¶
DeviceStatusChange defines the schema of the data to be sent to stats db when a device status gets changed
type Disk ¶
type Disk struct { // Size in bytes // TODO: uint64!!! Size float64 `json:"size" description:"Size of the disk in bytes"` // TODO: capture the below fields if required // Model represents the disk model, e.g., "Samsung 970 EVO Plus", "Western Digital Blue SN550" Model string `json:"model,omitempty" description:"Disk model, e.g., Samsung 970 EVO Plus, Western Digital Blue SN550"` // Vendor represents the disk manufacturer, e.g., "Samsung", "Western Digital" Vendor string `json:"vendor,omitempty" description:"Disk manufacturer, e.g., Samsung, Western Digital"` // Type represents the disk type, e.g., "SSD", "HDD", "NVMe" Type string `json:"type,omitempty" description:"Disk type, e.g., SSD, HDD, NVMe"` // Interface represents the disk interface, e.g., "SATA", "PCIe", "M.2" Interface string `json:"interface,omitempty" description:"Disk interface, e.g., SATA, PCIe, M.2"` // Read speed in bytes per second ReadSpeed uint64 `json:"read_speed,omitempty" description:"Read speed in bytes per second"` // Write speed in bytes per second WriteSpeed uint64 `json:"write_speed,omitempty" description:"Write speed in bytes per second"` }
Disk represents the disk information
type Encryptor ¶
Encryptor (DRAFT)
Warning: this is just a draft. And it might be moved to an Encryption package
TODO: it must support encryption of files/directories, otherwise we have to create another interface for the usecase
type ExecutionListItem ¶
ExecutionListItem is the result of the current executions.
type ExecutionRequest ¶
type ExecutionRequest struct { JobID string // ID of the job to execute ExecutionID string // ID of the execution EngineSpec *SpecConfig // Engine spec for the execution Resources *Resources // Resources for the execution Inputs []*StorageVolumeExecutor // Input volumes for the execution Outputs []*StorageVolumeExecutor // Output volumes for the results ResultsDir string // Directory to store the results PersistLogsDuration time.Duration // Duration to persist logs on disk ProvisionScripts map[string][]byte // (named) Scripts to run when initiating the execution PortsToBind []PortsToBind // List of ports to bind GatewayIP string // Gateway IP to use as dns resolver }
ExecutionRequest is the request object for executing a job
type ExecutionResult ¶
type ExecutionResult struct { STDOUT string `json:"stdout"` // STDOUT of the execution STDERR string `json:"stderr"` // STDERR of the execution ExitCode int `json:"exit_code"` // Exit code of the execution ErrorMsg string `json:"error_msg"` // Error message if the execution failed }
ExecutionResult is the result of an execution
func NewExecutionResult ¶
func NewExecutionResult(code int) *ExecutionResult
NewExecutionResult creates a new ExecutionResult object
func NewFailedExecutionResult ¶
func NewFailedExecutionResult(err error) *ExecutionResult
NewFailedExecutionResult creates a new ExecutionResult object for a failed execution It sets the error message from the provided error and sets the exit code to -1
type ExecutionStatus ¶
type ExecutionStatus string
ExecutionStatus is the status of an execution
const ( ExecutionStatusPending ExecutionStatus = "pending" ExecutionStatusRunning ExecutionStatus = "running" ExecutionStatusPaused ExecutionStatus = "paused" ExecutionStatusFailed ExecutionStatus = "failed" ExecutionStatusSuccess ExecutionStatus = "success" )
type Executor ¶
type Executor struct {
ExecutorType ExecutorType `json:"executor_type"`
}
Executor is the executor type
type ExecutorType ¶
type ExecutorType string
ExecutorType is the type of the executor
const ( ExecutorTypeDocker ExecutorType = "docker" ExecutorTypeFirecracker ExecutorType = "firecracker" ExecutorTypeWasm ExecutorType = "wasm" ExecutionStatusCodeSuccess = 0 )
func (ExecutorType) Compare ¶
func (e ExecutorType) Compare(other ExecutorType) (Comparison, error)
Compare compares two ExecutorType objects
func (ExecutorType) String ¶
func (e ExecutorType) String() string
String returns the string representation of the ExecutorType
type Executors ¶
type Executors []Executor
Executors is a list of Executor objects
func (*Executors) Compare ¶
func (e *Executors) Compare(other Executors) (Comparison, error)
Compare compares two Executors objects
type FreeResources ¶
type FreeResources struct { BaseDBModel Resources }
FreeResources represents the free resources of the machine
type GPU ¶
type GPU struct { // Index is the self-reported index of the device in the system Index int `json:"index" description:"GPU index in the system"` // Vendor is the maker of the GPU, e.g. NVidia, AMD, Intel Vendor GPUVendor `json:"vendor" description:"GPU vendor, e.g., NVidia, AMD, Intel"` // PCIAddress is the PCI address of the device, in the format AAAA:BB:CC.C // Used to discover the correct device rendering cards PCIAddress string `json:"pci_address" description:"PCI address of the device, in the format AAAA:BB:CC.C"` // Model represents the GPU model name, e.g., "Tesla T4", "A100" Model string `json:"model" description:"GPU model, e.g., Tesla T4, A100"` // VRAM is the total amount of VRAM on the device // TODO: uint64!! VRAM float64 `json:"vram" description:"Total amount of VRAM on the device"` // UUID is the unique identifier of the device UUID string `json:"uuid" description:"Unique identifier of the device"` // Gorm fields // Team, is this the right way to do this? What is the best practice we're following? ResourceID string `json:"-" gorm:"foreignKey:ID"` }
GPU represents the GPU information
func (*GPU) Compare ¶
func (g *GPU) Compare(other GPU) (Comparison, error)
Compare compares the GPU with the other GPU
type GPUConnector ¶
type GPUConnector interface { GetGPUs() (GPUs, error) GetGPUUsage(uuid string) (float64, error) Shutdown() error }
GPUConnector vendor-specific adapter that interacts with actual GPU hardware by using vendor-specific libraries
type GPUManager ¶
type GPUManager interface { GetGPUs() (GPUs, error) GetGPUUsage(uuid ...string) (GPUs, error) Shutdown() error }
GPUManager defines the interface for managing GPU resources.
type GPUVendor ¶
type GPUVendor string
func ParseGPUVendor ¶
ParseGPUVendor parses the GPU vendor string and returns the corresponding GPUVendor enum
type GPUs ¶
type GPUs []GPU
func (GPUs) GetWithIndex ¶
GetWithIndex returns the GPU with the specified index
func (GPUs) MaxFreeVRAMGPU ¶
MaxFreeVRAMGPU returns the GPU with the maximum free VRAM from the list of GPUs
type GeoIPLocator ¶
type GeoIPLocator interface { Country(ipAddress net.IP) (*geoip2.Country, error) City(ipAddress net.IP) (*geoip2.City, error) }
GeoIPLocator returns the info about an IP.
type HardwareCapability ¶
type HardwareCapability struct { Executors Executors `json:"executor" description:"Executor type required for the job (docker, vm, wasm, or others)"` JobTypes JobTypes `` /* 148-byte string literal not displayed */ Resources Resources `json:"resources" description:"Resources required for the job"` Libraries Libraries `json:"libraries" description:"Libraries required for the job"` Localities Localities `json:"locality" description:"Preferred localities of the machine for execution"` Connectivity Connectivity `json:"connectivity" description:"Network configuration required"` Price PricesInformation `json:"price" description:"Pricing information"` Time TimeInformation `json:"time" description:"Time constraints"` KYCs KYCs }
HardwareCapability represents the hardware capability of the machine
func (*HardwareCapability) Add ¶
func (c *HardwareCapability) Add(other HardwareCapability) error
Add adds the resources of the given HardwareCapability to the current HardwareCapability
func (*HardwareCapability) Compare ¶
func (c *HardwareCapability) Compare(other HardwareCapability) (Comparison, error)
Compare compares two HardwareCapability objects
func (*HardwareCapability) Subtract ¶
func (c *HardwareCapability) Subtract(cap HardwareCapability) error
Subtract subtracts the resources of the given HardwareCapability from the current HardwareCapability
type HardwareManager ¶
type HardwareManager interface { GetMachineResources() (MachineResources, error) GetUsage() (Resources, error) GetFreeResources() (Resources, error) }
HardwareManager defines the interface for managing machine resources.
type HealthCheckManifest ¶
type HealthCheckManifest struct { Type string `json:"type"` // type of healthcheck Exec []string `json:"exec"` // command to execute Endpoint string `json:"endpoint"` // endpoint to check Response HealthCheckResponse `json:"response"` // expected response Interval time.Duration `json:"interval"` // interval between healthchecks }
type HealthCheckResponse ¶
type KYC ¶
type KYC struct { Type string `json:"type" description:"Type of KYC"` Data string `json:"data" description:"Data required for KYC"` }
KYC represents the KYC data
type Libp2pConfig ¶
type Libp2pConfig struct { DHTPrefix string PrivateKey crypto.PrivKey BootstrapPeers []multiaddr.Multiaddr Rendezvous string Server bool Scheduler *bt.Scheduler CustomNamespace string ListenAddress []string PeerCountDiscoveryLimit int GracePeriodMs int GossipMaxMessageSize int BootstrapMaxSleep int // in minutes Memory int // in MB FileDescriptors int }
Libp2pConfig holds the libp2p configuration
type Library ¶
type Library struct { Name string `json:"name" description:"Name of the library"` Constraint string `json:"constraint" description:"Constraint of the library"` Version string `json:"version" description:"Version of the library"` }
Library represents the libraries
type Localities ¶
type Localities []Locality
func (*Localities) Add ¶
func (l *Localities) Add(other Localities) error
func (*Localities) Compare ¶
func (l *Localities) Compare(other Localities) (Comparison, error)
func (*Localities) Contains ¶
func (l *Localities) Contains(locality Locality) bool
func (*Localities) Subtract ¶
func (l *Localities) Subtract(other Localities) error
type Locality ¶
type Locality struct { Kind string `json:"kind" description:"Kind of the region (geographic, nunet-defined, etc)"` Name string `json:"name" description:"Name of the region"` }
Locality represents the locality
type LogStreamRequest ¶
type LogStreamRequest struct { JobID string // ID of the job ExecutionID string // ID of the execution Tail bool // Tail the logs Follow bool // Follow the logs }
LogStreamRequest is the request object for streaming logs from an execution
type MMDSConfig ¶
type MMDSConfig struct {
NetworkInterface []string `json:"network_interfaces"`
}
type MMDSMetadata ¶
type MMDSMsg ¶
type MMDSMsg struct { Latest struct { Metadata struct { MMDSMetadata } `json:"meta-data"` } `json:"latest"` }
type MachineConfig ¶
type MachineResources ¶
type MachineResources struct { BaseDBModel Resources }
MachineResources represents the total resources of the machine
type MessageEnvelope ¶
type MessageEnvelope struct { Type MessageType Data []byte }
type MessageInfo ¶
type MessageInfo struct {
Info string `json:"info"` // Message information
}
MessageInfo is a stub. Please expand it or completely change it based on requirements.
type MessageType ¶
type MessageType string
type NetConfig ¶
type NetConfig struct {
NetworkSpec SpecConfig `json:"network_spec"` // Network specification
}
NetConfig is a stub. Please expand it or completely change it based on requirements.
func (*NetConfig) GetNetworkConfig ¶
func (nc *NetConfig) GetNetworkConfig() *SpecConfig
type NetworkConfig ¶
type NetworkConfig struct { Type NetworkType // libp2p Libp2pConfig // nats NATSUrl string }
type NetworkInfo ¶
type NetworkInfo struct { // Bandwidth in bits per second (b/s) Bandwidth uint64 // NetworkType represents the network type, e.g., "Ethernet", "Wi-Fi", "Cellular" NetworkType string }
NetworkInfo represents the network information TODO: not yet used, but can be used to capture the network information
type NetworkInterfaces ¶
type NetworkStats ¶
NetworkStats should contain all network info the user is interested in. for now there's only peerID and listening address but reachability, local and remote addr etc... can be added when necessary.
type NetworkType ¶
type NetworkType string
const ( Libp2pNetwork NetworkType = "libp2p" NATSNetwork NetworkType = "nats" )
type NewDeviceOnboarded ¶
type NewDeviceOnboarded struct { PeerID string CPU float32 RAM float32 Network float32 DedicatedTime float32 Timestamp float32 }
NewDeviceOnboarded defines the schema of the data to be sent to stats db when a new device gets onboarded
type NewService ¶
type NewService struct { ServiceID string ServiceName string ServiceDescription string Timestamp float32 }
NewService defines the schema of the data to be sent to stats db when a new service gets registered in the platform
type NtxPayment ¶
type NtxPayment struct { CallID float32 ServiceID string AmountOfNtx int32 PeerID string SuccessFailStatus string Timestamp float32 }
NtxPayment defines the schema of the data to be sent to stats db when a payment is made to device for the completion of service.
type OnboardedResources ¶
type OnboardedResources struct { BaseDBModel Resources }
OnboardedResources represents the onboarded resources of the machine
type OnboardingConfig ¶
type OnboardingConfig struct { BaseDBModel IsOnboarded bool `json:"is_onboarded"` // OnboardedResources - resources that are onboarded // this is a transient field and not stored in the database directly // it is populated using the ResourceManager OnboardedResources Resources `json:"onboarded_resources,omitempty" gorm:"-" clover:"-"` }
OnboardingConfig - parameters to configure onboarding
type OnboardingManager ¶
type OnboardingManager interface { IsOnboarded() (bool, error) Info(ctx context.Context) (OnboardingConfig, error) Onboard(ctx context.Context, config OnboardingConfig) (OnboardingConfig, error) Offboard(ctx context.Context) error }
OnboardingManager - interface for onboarding
type PortsToBind ¶
type Preference ¶
type Preference struct { TypeName string Strength PreferenceString DefaultComparatorOverride Comparator }
type PreferenceString ¶
type PreferenceString string
const ( Hard PreferenceString = "Hard" Soft PreferenceString = "Soft" )
type PriceInformation ¶
type PriceInformation struct { Currency string `json:"currency" description:"Currency used for pricing"` CurrencyPerHour int `json:"currency_per_hour" description:"Price charged per hour"` TotalPerJob int `json:"total_per_job" description:"Maximum total price or budget of the job"` Preference int `json:"preference" description:"Pricing preference"` }
PriceInformation represents the pricing information
func (*PriceInformation) Compare ¶
func (p *PriceInformation) Compare(other PriceInformation) (Comparison, error)
func (*PriceInformation) Equal ¶
func (p *PriceInformation) Equal(price PriceInformation) bool
type PricesInformation ¶
type PricesInformation []PriceInformation
func (*PricesInformation) Add ¶
func (ps *PricesInformation) Add(other PricesInformation) error
func (*PricesInformation) Compare ¶
func (ps *PricesInformation) Compare(other PricesInformation) (Comparison, error)
func (*PricesInformation) Contains ¶
func (ps *PricesInformation) Contains(price PriceInformation) bool
func (*PricesInformation) Subtract ¶
func (ps *PricesInformation) Subtract(other PricesInformation) error
type RAM ¶
type RAM struct { // Size in bytes // TODO: uint64!!! Size float64 `json:"size" description:"Size of the RAM in bytes"` // TODO: capture the below fields if required // Clock speed in Hz ClockSpeed uint64 `json:"clock_speed,omitempty" description:"Clock speed of the RAM in Hz"` // Type represents the RAM type, e.g., "DDR4", "DDR5", "LPDDR4" Type string `json:"type,omitempty" description:"RAM type, e.g., DDR4, DDR5, LPDDR4"` }
RAM represents the RAM information
type RequestTracker ¶
type RequestTracker struct { BaseDBModel ServiceType string NodeID string CallID int64 Status string RequestID string MaxTokens int }
RequestTracker defines the schema of the data to be saved in db for tracking the status of the deployement request
nolint:nolintlint // Deprecated: Should be removed soon since its use has run out when statsdb was deprecated.
type ResourceAllocation ¶
type ResourceAllocation struct { BaseDBModel AllocationID string `json:"allocation_id"` Resources }
ResourceAllocation represents the allocation of resources for a job
type ResourceManager ¶
type ResourceManager interface { // CommitResources preallocates the resources required by the jobs CommitResources(context.Context, CommittedResources) error // UncommitResources releases the resources that were preallocated for the jobs UncommitResources(context.Context, string) error // AllocateResources allocates the resources required by a job AllocateResources(context.Context, ResourceAllocation) error // DeallocateResources deallocates the resources required by a job DeallocateResources(context.Context, string) error // GetTotalAllocation returns the total allocations for the jobs GetTotalAllocation() (Resources, error) // GetFreeResources returns the free resources in the allocation pool GetFreeResources(ctx context.Context) (FreeResources, error) // GetOnboardedResources returns the onboarded resources of the machine GetOnboardedResources(context.Context) (OnboardedResources, error) // UpdateOnboardedResources updates the onboarded resources of the machine in the database UpdateOnboardedResources(context.Context, Resources) error }
ResourceManager is an interface that defines the methods to manage the resources of the machine
type Resources ¶
type Resources struct { CPU CPU `json:"cpu" gorm:"embedded;embeddedPrefix:cpu_"` GPUs GPUs `json:"gpus,omitempty" gorm:"foreignKey:ResourceID"` RAM RAM `json:"ram" gorm:"embedded;embeddedPrefix:ram_"` Disk Disk `json:"disk" gorm:"embedded;embeddedPrefix:disk_"` }
Resources represents the resources of the machine
func (*Resources) Compare ¶
func (r *Resources) Compare(other Resources) (Comparison, error)
Compare compares two Resources objects
type ServiceCall ¶
type ServiceCall struct { CallID float32 PeerIDOfServiceHost string ServiceID string CPUUsed float32 MaxRAM float32 MemoryUsed float32 NetworkBwUsed float32 TimeTaken float32 Status string AmountOfNtx int32 Timestamp float32 }
ServiceCall defines the schema of the data to be sent to stats db when a host machine accepts a deployement request
type ServiceRemove ¶
ServiceRemove defines the schema of the data to be sent to stats db when a new service gets removed from the platform
type ServiceStatus ¶
type ServiceStatus struct { CallID float32 PeerIDOfServiceHost string ServiceID string Status string Timestamp float32 }
ServiceStatus defines the schema of update the status of service to stats db of the job being executed on host machine
type SpecConfig ¶
type SpecConfig struct { // Type of the spec (e.g. docker, firecracker, storage, etc.) Type string `json:"type"` // Params of the spec Params map[string]interface{} `json:"params,omitempty"` }
SpecConfig represents a configuration for a spec A SpecConfig can be used to define an engine spec, a storage volume, etc.
func NewSpecConfig ¶
func NewSpecConfig(t string) *SpecConfig
NewSpecConfig creates a new SpecConfig with the given type
func (*SpecConfig) IsEmpty ¶
func (s *SpecConfig) IsEmpty() bool
IsEmpty returns true if the spec config is empty
func (*SpecConfig) IsType ¶
func (s *SpecConfig) IsType(t string) bool
IsType returns true if the current SpecConfig is of the given type
func (*SpecConfig) Normalize ¶
func (s *SpecConfig) Normalize()
Normalize ensures that the spec config is in a valid state
func (*SpecConfig) Validate ¶
func (s *SpecConfig) Validate() error
Validate checks if the spec config is valid
func (*SpecConfig) WithParam ¶
func (s *SpecConfig) WithParam(key string, value interface{}) *SpecConfig
WithParam adds a new key-value pair to the spec params
type StorageVolume ¶
type StorageVolume struct { BaseDBModel // CID is the content identifier of the storage volume. // // Warning: CID must be updated ONLY when locking volume (aka when volume was // is set to read-only) // // Be aware: Before relying on data's CID, be aware that it might be encrypted ( // EncryptionType might be checked first if needed) // // TODO-maybe [type]: maybe it should be of type cid.CID CID string // Path points to the root of a DIRECTORY where data may be stored. Path string // ReadOnly indicates whether the storage volume is read-only or not. ReadOnly bool // Private indicates whether the storage volume is private or not. // If it's private, it shouldn't be shared with other nodes and it shouldn't // be persisted after the job is finished. // Practical application: if private, peer maintaining it shouldn't publish // its CID as if it was available to be worked on by other jobs. Private bool // EncryptionType indicates the type of encryption used for the storage volume. // In case no encryption is used, the value will be EncryptionTypeNull EncryptionType EncryptionType }
StorageVolume contains the location (FS path) of a directory where certain data may be stored and metadata about the volume itself + data (if any).
Be aware that StorageVolume might not contain any data within it, specially when it's just created using the VolumeController, there will be no data in it by default.
TODO-maybe [job]: should volumes be related to a job or []job?
TODO-maybe: most of the fields should be private, callers shouldn't be able to altere the state of the volume except when using certain methods
type StorageVolumeExecutor ¶
type StorageVolumeExecutor struct { // Type of the volume (e.g. bind) Type string `json:"type"` // Source path of the volume on the host Source string `json:"source"` // Target path of the volume in the execution Target string `json:"target"` // ReadOnly flag to mount the volume as read-only ReadOnly bool `json:"readonly"` }
StorageVolumeExecutor represents a prepared storage volume that can be mounted to an execution
type TimeInformation ¶
type TimeInformation struct { Units string `json:"units" description:"Time units"` MaxTime int `json:"max_time" description:"Maximum time that job should run"` Preference int `json:"preference" description:"Time preference"` }
TimeInformation represents the time constraints
func (*TimeInformation) Add ¶
func (t *TimeInformation) Add(other TimeInformation) error
func (*TimeInformation) Compare ¶
func (t *TimeInformation) Compare(other TimeInformation) (Comparison, error)
func (*TimeInformation) Subtract ¶
func (t *TimeInformation) Subtract(other TimeInformation) error
func (*TimeInformation) TotalTime ¶
func (t *TimeInformation) TotalTime() int