core

package
v0.0.0-...-1826292 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

* Copyright 2018 Yuji Ito <[email protected]> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright 2018 Yuji Ito <[email protected]> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright 2018 Yuji Ito <[email protected]> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright 2018 Yuji Ito <[email protected]> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright 2018 Yuji Ito <[email protected]> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

View Source
const (
	ResourceTypeAccount = ResourceType("account")
	ResourceTypeNode    = ResourceType("node")
	ResourceTypePod     = ResourceType("pod")
	ResourceTypeRecord  = ResourceType("record")
)

Variables

View Source
var ContainerRuntimeAccepted = []string{
	"core:dev1",
}
View Source
var ContainerRuntimeRequired = []string{
	"go:1.19",
	"go:1.20",
}
View Source
var NODE_NAME_EXPRESSION = regexp.MustCompile("^[0-9a-f]{32}$")

node id format is equal to colonio node ids

Functions

func GenerateAccountUuid

func GenerateAccountUuid(name string) string

use sha256 hash as account's uuid

func GeneratePodUuid

func GeneratePodUuid() string

func ValidateNodeId

func ValidateNodeId(name string) error

func ValidatePodUuid

func ValidatePodUuid(id string) error

func ValidateTimestamp

func ValidateTimestamp(timestamp string) error

Types

type Account

type Account struct {
	Meta  *ObjectMeta   `json:"meta"`
	State *AccountState `json:"state"`
}

func (*Account) Validate

func (account *Account) Validate() error

type AccountNodeState

type AccountNodeState struct {
	Name      string   `json:"name"`
	Timestamp string   `json:"timestamp"`
	NodeType  NodeType `json:"nodeType"`
	Position  *Vector3 `json:"position,omitempty"`
}

type AccountPodState

type AccountPodState struct {
	RunningNode string `json:"runningNode"`
	Timestamp   string `json:"timestamp"`
}

type AccountState

type AccountState struct {
	// map describing pod's uuid and pod state
	Pods map[string]AccountPodState `json:"pods"`
	// map describing nid and timestamp of keepalive
	Nodes map[string]AccountNodeState `json:"nodes"`
}

type ContainerSpec

type ContainerSpec struct {
	Name          string        `json:"name"`
	Image         string        `json:"image"`
	Runtime       []string      `json:"runtime"`
	Args          []string      `json:"args"`
	Env           []EnvVar      `json:"env"`
	RestartPolicy RestartPolicy `json:"restartPolicy"`
}

type ContainerState

type ContainerState struct {
	Running    *ContainerStateRunning    `json:"running,omitempty"`
	Terminated *ContainerStateTerminated `json:"terminated,omitempty"`
	Unknown    *ContainerStateUnknown    `json:"unknown,omitempty"`
}

type ContainerStateRunning

type ContainerStateRunning struct {
	StartedAt string `json:"startedAt"`
}

type ContainerStateTerminated

type ContainerStateTerminated struct {
	FinishedAt string `json:"finishedAt"`
	ExitCode   int    `json:"exitCode"`
}

type ContainerStateUnknown

type ContainerStateUnknown struct {
	Timestamp string `json:"timestamp"`
	Reason    string `json:"reason"`
}

type ContainerStatus

type ContainerStatus struct {
	ContainerID string                    `json:"containerID,omitempty"`
	Image       string                    `json:"image,omitempty"`
	LastState   *ContainerStateTerminated `json:"lastState,omitempty"`
	State       ContainerState            `json:"state"`
}

type EnvVar

type EnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type MarshalRequest

type MarshalRequest struct {
}

type MarshalResponse

type MarshalResponse struct {
	Record []byte `json:"record"`
}

type NodeType

type NodeType string
const (
	NodeTypeMobile      NodeType = "Mobile"
	NodeTypeSmallDevice NodeType = "SmallDevice"
	NodeTypePC          NodeType = "PC"
	NodeTypeServer      NodeType = "Server"
	NodeTypeGrass       NodeType = "Grass"
	NodeTypeOther       NodeType = "Other"
)

type ObjectMeta

type ObjectMeta struct {
	Type              ResourceType `json:"type"`
	Name              string       `json:"name"`
	Owner             string       `json:"owner"`
	CreatorNode       string       `json:"creatorNode"`
	Uuid              string       `json:"uuid"`
	DeletionTimestamp string       `json:"deletionTimestamp"`
}

func (*ObjectMeta) Validate

func (meta *ObjectMeta) Validate(t ResourceType) error

type OutputRequest

type OutputRequest struct {
	Payload []byte `json:"payload"`
}

type OutputResponse

type OutputResponse struct {
	Length int `json:"length"`
}

type Pod

type Pod struct {
	Meta   *ObjectMeta `json:"meta"`
	Spec   *PodSpec    `json:"spec"`
	Status *PodStatus  `json:"status"`
}

func (*Pod) Validate

func (pod *Pod) Validate(mustStatus bool) error

type PodSpec

type PodSpec struct {
	Containers    []ContainerSpec `json:"containers"`
	TargetNode    string          `json:"targetNode"`
	Scheduler     *SchedulerSpec  `json:"scheduler"`
	EnableMigrate bool            `json:"enableMigrate"`
}

type PodStatus

type PodStatus struct {
	RunningNode       string            `json:"runningNode"`
	Position          *Vector3          `json:"position,omitempty"`
	ContainerStatuses []ContainerStatus `json:"containerStatuses"`
}

type ReadyRequest

type ReadyRequest struct {
}

types to pass from application to node manager

type ReadyResponse

type ReadyResponse struct {
}

type Record

type Record struct {
	Meta *ObjectMeta `json:"meta"`
	Data *RecordData `json:"data"`
}

func (*Record) Validate

func (record *Record) Validate() error

type RecordData

type RecordData struct {
	// key: container name
	Entries map[string]RecordEntry `json:"entries"`
}

func (*RecordData) Validate

func (data *RecordData) Validate() error

type RecordEntry

type RecordEntry struct {
	Timestamp string `json:"timestamp"`
	Record    []byte
}

type ResourceType

type ResourceType string

type RestartPolicy

type RestartPolicy string
const (
	RestartPolicyDisable         RestartPolicy = "Disable"
	RestartPolicyAlways          RestartPolicy = "Always"
	RestartPolicyStrictExited    RestartPolicy = "StrictExited"
	RestartPolicyStrictSucceeded RestartPolicy = "StrictSucceeded"
	RestartPolicyStrictFailed    RestartPolicy = "StrictFailed"
	RestartPolicyOnce            RestartPolicy = "Once"
)

type SchedulerSpec

type SchedulerSpec struct {
	Type string `json:"type"`
}

type SetupRequest

type SetupRequest struct {
	IsInitialize bool   `json:"isInitialize"`
	Record       []byte `json:"record"`
}

types to pass from node manager to application

type SetupResponse

type SetupResponse struct {
}

type TeardownRequest

type TeardownRequest struct {
	IsFinalize bool `json:"isFinalizeT"`
}

type TeardownResponse

type TeardownResponse struct {
	Record []byte `json:"record"`
}

type Vector2

type Vector2 struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

type Vector3

type Vector3 struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
	Z float64 `json:"z"`
}

Jump to

Keyboard shortcuts

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