structs

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinSlotDuration = 10 * time.Minute
)

Variables

View Source
var (
	ErrDurationIsTooShort = errors.New("duration is too short")
)

Functions

func ParseGPUCount

func ParseGPUCount(ty string) (pb.GPUCount, error)

func ParseNetworkType

func ParseNetworkType(ty string) (pb.NetworkType, error)

func ParseOrderType

func ParseOrderType(ty string) (pb.OrderType, error)

func RequireHeaderInt64

func RequireHeaderInt64(md metadata.MD, name string) (int64, error)

func ValidateResources

func ValidateResources(resources *pb.Resources) error

ValidateResources validates the specified protobuf object to be wrapped.

Types

type ByPrice

type ByPrice []*Order

ByPrice implements sort.Interface; it allows for sorting Orders by Price field.

func (ByPrice) Len

func (a ByPrice) Len() int

func (ByPrice) Less

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

func (ByPrice) Swap

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

type DealRequest

type DealRequest struct {
	*sonm.DealRequest
}

func NewDealRequest

func NewDealRequest(deal *sonm.DealRequest) (*DealRequest, error)

type ImagePush

type ImagePush struct {
	sonm.Hub_PushTaskServer
	// contains filtered or unexported fields
}

func NewImagePush

func NewImagePush(stream sonm.Hub_PushTaskServer) (*ImagePush, error)

func (*ImagePush) DealId

func (p *ImagePush) DealId() string

func (*ImagePush) ImageSize

func (p *ImagePush) ImageSize() int64

type Order

type Order struct {
	*pb.Order
}

Order represents a safe order wrapper.

This is used to decompose the validation out of the protocol. All methods must return the valid sub-structures.

func NewOrder

func NewOrder(o *pb.Order) (*Order, error)

func (*Order) GetDuration

func (o *Order) GetDuration() time.Duration

func (*Order) GetID

func (o *Order) GetID() string

func (*Order) GetPrice

func (o *Order) GetPrice() *big.Int

func (*Order) GetSlot

func (o *Order) GetSlot() *Slot

func (*Order) IsBid

func (o *Order) IsBid() bool

func (*Order) PriceAsBigInt

func (o *Order) PriceAsBigInt() *big.Int

func (*Order) SetID

func (o *Order) SetID(ID string)

func (*Order) Unwrap

func (o *Order) Unwrap() *pb.Order

type Resources

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

Resources wraps the underlying protobuf object with full validation, such as checking all required fields exists etc.

func NewResources

func NewResources(resources *pb.Resources) (*Resources, error)

NewResources constructs a new resources wrapper using provided protobuf object.

func (*Resources) Eq

func (r *Resources) Eq(o *Resources) bool

Eq method tests for self and other values to be equal.

func (*Resources) GetCpuCores

func (r *Resources) GetCpuCores() uint64

GetCpuCores returns the total number of logical CPU cores.

func (*Resources) GetGPUCount

func (r *Resources) GetGPUCount() int

GetGPUCount returns the number of GPU devices required.

func (*Resources) GetMemoryInBytes

func (r *Resources) GetMemoryInBytes() uint64

GetMemoryInBytes returns the total number of memory bytes requested.

func (*Resources) Unwrap

func (r *Resources) Unwrap() *pb.Resources

Unwrap unwraps this resources yielding the underlying protobuf object.

type Slot

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

func NewSlot

func NewSlot(s *pb.Slot) (*Slot, error)

func (*Slot) Compare

func (s *Slot) Compare(another *Slot) bool

Compare compares two slots, returns true if "s" slot is fits into an "another" slot

func (*Slot) GetResources

func (s *Slot) GetResources() *Resources

func (*Slot) MarshalJSON

func (s *Slot) MarshalJSON() ([]byte, error)

func (*Slot) UnmarshalJSON

func (s *Slot) UnmarshalJSON(data []byte) error

func (*Slot) Unwrap

func (s *Slot) Unwrap() *pb.Slot

type StartTaskRequest

type StartTaskRequest struct {
	*sonm.HubStartTaskRequest
}

func NewStartTaskRequest

func NewStartTaskRequest(request *sonm.HubStartTaskRequest) (*StartTaskRequest, error)

func (*StartTaskRequest) GetDeal

func (r *StartTaskRequest) GetDeal() *sonm.Deal

func (*StartTaskRequest) GetDealId

func (r *StartTaskRequest) GetDealId() string

type TaskResources

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

func NewTaskResources

func NewTaskResources(r *pb.TaskResourceRequirements) (*TaskResources, error)

func (*TaskResources) RequiresGPU

func (r *TaskResources) RequiresGPU() bool

func (*TaskResources) ToCgroupResources

func (r *TaskResources) ToCgroupResources() *specs.LinuxResources

func (*TaskResources) ToContainerResources

func (r *TaskResources) ToContainerResources(cgroupParent string) container.Resources

func (*TaskResources) ToUsage

func (r *TaskResources) ToUsage() resource.Resources

Jump to

Keyboard shortcuts

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