contract

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accessor

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

Accessor is an accessor to in-memory contracts.

func NewContractAccessor

func NewContractAccessor() *Accessor

NewContractAccessor returns new contract accessor's ptr.

func (Accessor) Get

func (c Accessor) Get(id ID) (*Contract, error)

Get returns contract data from in-memory map.

func (*Accessor) Post

func (c *Accessor) Post(contractorName string, id ID,
	availableServices []string, quota *pb.ContractQuota) (McOpsID, error)

Post inserts new contract in in-memory map if contractId does not exist.

func (*Accessor) Update

func (c *Accessor) Update(contractorName string, id ID,
	availableServices []string, quota *pb.ContractQuota) error

Update updates contract data by contractID. Not implemented yet.

type Contract

type Contract struct {
	ContractorName    string            `json:"contractorName"`
	ID                ID                `json:"contractID"`
	AvailableServices []string          `json:"availableServices,omitempty"`
	McOpsID           McOpsID           `json:"mcOpsId,omitempty"`
	LastUpdatedTs     *LastUpdatedTime  `json:"lastUpdatedTs"`
	Quota             *pb.ContractQuota `json:"quota"`
}

Contract represents a contract data

type ID

type ID string

ID is a global unique ID for the contracts. ID is generated by CBP or external site.

type LastUpdatedTime

type LastUpdatedTime struct {
	time.Time
}

LastUpdatedTime renamed time.Time type.

func (LastUpdatedTime) Timestamppb

func (ts LastUpdatedTime) Timestamppb() *timestamppb.Timestamp

Timestamppb converts time.Time type to timestamppb.Timestamp.

func (*LastUpdatedTime) UnmarshalJSON

func (ts *LastUpdatedTime) UnmarshalJSON(data []byte) error

UnmarshalJSON parses the Unix time and stores the result in ts

type McOpsID

type McOpsID uuid.UUID

McOpsID means multi-cluster operations ID. It's randomly generated by tks-contract.

func GenerateMcOpsID

func GenerateMcOpsID() McOpsID

GenerateMcOpsID randomly generates new UUID.

func (McOpsID) String

func (m McOpsID) String() string

String converts uuid.UUID type to string

Jump to

Keyboard shortcuts

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