model

package
v0.0.0-...-260b785 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ArtifactURL is the environment variable used to download the artifact from
	ArtifactURL string = "ARTIFACT_URL"

	// ArtifactToken is the token used to authenticate
	ArtifactToken string = "ARTIFACT_TOKEN"

	// ArtifactProject is the environment variable used to identify the project id of the service
	ArtifactProject string = "ARTIFACT_PROJECT"

	// ArtifactService is the environment variable used to identify the id of the service
	ArtifactService string = "ARTIFACT_SERVICE"

	// ArtifactVersion is the environment variable used to identify the version of the service
	ArtifactVersion string = "ARTIFACT_VERSION"
)
View Source
const (
	// DefaultRequestRetries specifies the default values of service request retries
	DefaultRequestRetries int32 = 3
	// DefaultRequestTimeout specifies the default values of service request timeouts
	DefaultRequestTimeout int64 = 180 // Time in seconds
)
View Source
const DockerType string = "docker"

DockerType is the secretType:file

View Source
const EnvType string = "env"

EnvType is the secretType:file

View Source
const FileType string = "file"

FileType is the secretType:file

View Source
const ServiceRoleCluster string = "cluster"

ServiceRoleCluster is used to provide Type Cluster to role

View Source
const ServiceRoleProject string = "project"

ServiceRoleProject is used to provide Type Project to role

View Source
const Version string = "0.21.5"

Version represents the current runner version

Variables

This section is empty.

Functions

This section is empty.

Types

type Affinity

type Affinity struct {
	ID               string             `json:"id" yaml:"id"`
	Type             AffinityType       `json:"type" yaml:"type"`         // node or service
	Weight           int32              `json:"weight" yaml:"weight"`     // -100 to 100
	Operator         AffinityOperator   `json:"operator" yaml:"operator"` // preferred or required
	TopologyKey      string             `json:"topologyKey" yaml:"topologyKey"`
	Projects         []string           `json:"projects" yaml:"projects"`
	MatchExpressions []MatchExpressions `json:"matchExpressions" yaml:"matchExpressions"`
}

Affinity describes the affinity rules of a service

type AffinityOperator

type AffinityOperator string

AffinityOperator describes the type of operator

const (
	// AffinityOperatorPreferred scheduling on particular node is preferred
	AffinityOperatorPreferred AffinityOperator = "preferred"

	// AffinityOperatorRequired scheduling on partiuclar node is required
	AffinityOperatorRequired AffinityOperator = "required"
)

type AffinityType

type AffinityType string

AffinityType describe the type of affinity it can be either node (corresponds to kubernetes nodes) or service (corresponds to kubernetes pod)

const (
	// AffinityTypeNode is used for kubernetes node resource
	AffinityTypeNode AffinityType = "node"

	// AffinityTypeService is used for kubernetes service resource
	AffinityTypeService AffinityType = "service"
)

type AutoScaleAuthRef

type AutoScaleAuthRef struct {
	SecretMapping []AutoScaleAuthRefMapping `json:"secretMapping" yaml:"secretMapping"`
}

AutoScaleAuthRef describes the authentication reference for a scaler

type AutoScaleAuthRefMapping

type AutoScaleAuthRefMapping struct {
	Parameter string `json:"param" yaml:"param"`
	Key       string `json:"key" yaml:"key"`
}

AutoScaleAuthRefMapping describes the mapping between the keys of the secret and parameters of the scaler

type AutoScaleConfig

type AutoScaleConfig struct {
	PollingInterval  int32 `json:"pollingInterval" yaml:"pollingInterval"`   // Default 15 (in seconds)
	CoolDownInterval int32 `json:"coolDownInterval" yaml:"coolDownInterval"` // Default 120 (in seconds)

	MinReplicas int32 `json:"minReplicas" yaml:"minReplicas"` // Default 1
	MaxReplicas int32 `json:"maxReplicas" yaml:"maxReplicas"` // Default 100

	Triggers []AutoScaleTrigger `json:"triggers,omitempty" yaml:"triggers,omitempty"`
}

AutoScaleConfig describes the config used to scale a service

type AutoScaleTrigger

type AutoScaleTrigger struct {
	Name             string            `json:"name" yaml:"name"`
	Type             string            `json:"type" yaml:"type"`
	MetaData         map[string]string `json:"metadata" yaml:"metadata"`
	AuthenticatedRef *AutoScaleAuthRef `json:"authRef" yaml:"authRef"` // Authentication ref is optional
}

AutoScaleTrigger describes the config of a scaler

type CloudEventPayload

type CloudEventPayload struct {
	SpecVersion string `json:"specversion"`
	Type        string `json:"type"`
	Source      string `json:"source"`
	ID          string `json:"id"`
	Time        string `json:"time"`
	Data        struct {
		Path string         `json:"path"`
		Meta ServiceRequest `json:"meta"`
	} `json:"data"`
}

CloudEventPayload is the the JSON event spec by Cloud Events Specification

type Config

type Config map[string]Routes // key = projectId-serviceId

Config is a map with key = projectId-serviceId and the value being the routes([]Route)

type Docker

type Docker struct {
	Image           string          `json:"image" yaml:"image"`
	Cmd             []string        `json:"cmd" yaml:"cmd"`
	Secret          string          `json:"secret" yaml:"secret"`
	ImagePullPolicy ImagePullPolicy `json:"imagePullPolicy" yaml:"imagePullPolicy"`
}

Docker describes the docker configurations

type DriverType

type DriverType string

DriverType is used to describe which deployment target is to be used

const (
	// TypeIstio is the driver type used to target istio on kubernetes
	TypeIstio DriverType = "istio"

	// TypeDocker is the driver type used to target docker
	TypeDocker DriverType = "docker"
)

type EnvoyMetrics

type EnvoyMetrics struct {
	Stats []EnvoyStat `json:"stats"`
}

EnvoyMetrics is the metrics collected from envoy

type EnvoyStat

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

EnvoyStat describes the stats received from envoy

type GPUResource

type GPUResource struct {
	Type  string `json:"type" yaml:"type"`
	Value int64  `json:"value" yaml:"value"`
}

GPUResource describes the GPUs required by a task

type HTTPMatcher

type HTTPMatcher struct {
	Key        string             `json:"key,omitempty" yaml:"key,omitempty"`
	Value      string             `json:"value,omitempty" yaml:"value,omitempty"`
	Type       RouteHTTPMatchType `json:"type,omitempty" yaml:"type,omitempty"`
	IgnoreCase bool               `json:"ignoreCase,omitempty" yaml:"ignoreCase,omitempty"`
}

HTTPMatcher is matcher type

type ImagePullPolicy

type ImagePullPolicy string

ImagePullPolicy describes the image pull policy for docker config

const (
	// PullAlways is used for always pull policy
	PullAlways ImagePullPolicy = "always"

	// PullIfNotExists is use for pull if not exist locally pull policy
	PullIfNotExists ImagePullPolicy = "pull-if-not-exists"
)

type LogRequest

type LogRequest struct {
	TaskID    string       `json:"taskId"`
	ReplicaID string       `json:"replicaId"`
	Since     *int64       `json:"since"`
	SinceTime *metav1.Time `json:"sinceTime"`
	Tail      *int64       `json:"tail"`
	IsFollow  bool         `json:"isFollow"`
}

LogRequest represent log request structure

type MatchExpressions

type MatchExpressions struct {
	Key       string   `json:"key" yaml:"key"`
	Values    []string `json:"values" yaml:"values"`
	Attribute string   `json:"attribute" yaml:"attribute"`
	Operator  string   `json:"operator" yaml:"operator"`
}

MatchExpressions are a set of rules defined for scheduling pods on specifc nodes

type Matcher

type Matcher struct {
	URL     *HTTPMatcher   `json:"url,omitempty" yaml:"url,omitempty"`
	Headers []*HTTPMatcher `json:"headers,omitempty" yaml:"headers,omitempty"`
}

Matcher store the rules, which are used for traffic splitting between service

type Port

type Port struct {
	Name     string   `json:"name" yaml:"name"`
	Protocol Protocol `json:"protocol" yaml:"protocol"`
	Port     int32    `json:"port" yaml:"port"`
}

Port describes the port used by a task

type Project

type Project struct {
	ID          string `json:"id" yaml:"id"`
	Kind        string `json:"kind" yaml:"kind"`
	Environment string `json:"env" yaml:"env"`
}

Project describes the configuration of a project

type Protocol

type Protocol string

Protocol describes the protocol to be used for a port

const (
	// TCP is used for tcp based workloads
	TCP Protocol = "tcp"

	// HTTP is used for http based workloads
	HTTP Protocol = "http"
)

type ProxyMessage

type ProxyMessage struct {
	ActiveRequests int32  `json:"active,omitempty"`
	Project        string `json:"project,omitempty"`
	Service        string `json:"service,omitempty"`
	NodeID         string `json:"id,omitempty"`
	Version        string `json:"version,omitempty"`
}

ProxyMessage is the payload send by the proxy

type PubSubMessage

type PubSubMessage struct {
	ReplyTo string      `json:"replyTo"`
	Payload interface{} `json:"payload"`
}

PubSubMessage describes the format of pubsub send message

func (*PubSubMessage) Unmarshal

func (m *PubSubMessage) Unmarshal(ptr interface{}) error

Unmarshal parses the payload into the object provided

type PublicKeyPayload

type PublicKeyPayload struct {
	PemData string `json:"pem"`
}

PublicKeyPayload holds the pem encoded public key

type ReplicaInfo

type ReplicaInfo struct {
	ID     string `json:"id" yaml:"id"`
	Status string `json:"status" yaml:"status"`
}

ReplicaInfo describes structure of replica info

type RequestParams

type RequestParams struct {
	RequestID  string                 `json:"requestId"`
	Resource   string                 `json:"resource"`
	Op         string                 `json:"op"`
	Attributes map[string]string      `json:"attributes"`
	Headers    http.Header            `json:"headers"`
	Claims     map[string]interface{} `json:"claims"`
	Method     string                 `json:"method"`
	Path       string                 `json:"path"`
	Payload    interface{}            `json:"payload"`
}

RequestParams describes the params passed down in every request

type Resources

type Resources struct {
	CPU    int64        `json:"cpu" yaml:"cpu"`
	Memory int64        `json:"memory" yaml:"memory"`
	GPU    *GPUResource `json:"gpu,omitempty" yaml:"gpu,omitempty"`
}

Resources describes the resources to be used by a task

type Response

type Response struct {
	Error  string      `json:"error,omitempty"`
	Result interface{} `json:"result,omitempty"`
}

Response is the object returned by every handler to client

type Role

type Role struct {
	ID      string `json:"id" yaml:"id"`
	Project string `json:"project" yaml:"project"`
	Service string `json:"service" yaml:"service"`
	Type    string `json:"type" yaml:"type"` // Can be `project` or `cluster`
	Rules   []Rule `json:"rules" yaml:"rules"`
}

Role describes the configuration for the service role

type Route

type Route struct {
	ID             string        `json:"id" yaml:"id"`
	RequestRetries int32         `json:"requestRetries" yaml:"requestRetries"`
	RequestTimeout int64         `json:"requestTimeout" yaml:"requestTimeout"`
	Matchers       []*Matcher    `json:"matchers" yaml:"matchers"`
	Source         RouteSource   `json:"source" yaml:"source"`
	Targets        []RouteTarget `json:"targets" yaml:"targets"`
}

Route describes the parameters of a single route

func (*Route) SelectTarget

func (r *Route) SelectTarget(ctx context.Context, weight int32) (RouteTarget, error)

SelectTarget returns a target based on the weights assigned

type RouteHTTPMatchType

type RouteHTTPMatchType string

RouteHTTPMatchType defines http match type

const (
	// RouteHTTPMatchTypeExact is used for exact match
	RouteHTTPMatchTypeExact RouteHTTPMatchType = "exact"
	// RouteHTTPMatchTypeRegex is used for regex match
	RouteHTTPMatchTypeRegex RouteHTTPMatchType = "regex"
	// RouteHTTPMatchTypePrefix is used for prefix match
	RouteHTTPMatchTypePrefix RouteHTTPMatchType = "prefix"
	// RouteHTTPMatchTypeCheckPresence is used for only checking the presence of header in the http request
	RouteHTTPMatchTypeCheckPresence RouteHTTPMatchType = "check-presence"
)

type RouteSource

type RouteSource struct {
	Protocol   Protocol     `json:"protocol" yaml:"protocol"`
	Hosts      []string     `json:"hosts,omitempty" yaml:"hosts,omitempty"`
	Methods    []string     `json:"methods,omitempty" yaml:"methods,omitempty"`
	URL        string       `json:"url,omitempty" yaml:"url,omitempty"`
	RewriteURL string       `json:"rewrite,omitempty" yaml:"rewrite,omitempty"`
	Type       RouteURLType `json:"type,omitempty" yaml:"type,omitempty"`
	Port       int32        `json:"port,omitempty" yaml:"port,omitempty"`
}

RouteSource is the source of routing

type RouteTarget

type RouteTarget struct {
	Host    string          `json:"host,omitempty" yaml:"host,omitempty"`
	Port    int32           `json:"port,omitempty" yaml:"port,omitempty"`
	Weight  int32           `json:"weight,omitempty" yaml:"weight,omitempty"`
	Version string          `json:"version,omitempty" yaml:"version,omitempty"`
	Type    RouteTargetType `json:"type,omitempty" yaml:"type,omitempty"`
}

RouteTarget is the destination of routing

type RouteTargetType

type RouteTargetType string

RouteTargetType describes how the target should be selected

const (
	// RouteTargetVersion is used to route to versions of the same service
	RouteTargetVersion RouteTargetType = "version"

	// RouteTargetExternal is used to route to external services
	RouteTargetExternal RouteTargetType = "external"
)

type RouteURLType

type RouteURLType string

RouteURLType describes how the url should be evaluated / matched

const (
	// RoutePrefix is used for prefix matching
	RoutePrefix RouteURLType = "prefix"

	// RouteExact is used for matching the url exactly as it is
	RouteExact RouteURLType = "exact"
)

type Routes

type Routes []*Route

Routes describes the configuration for the routing module

type Rule

type Rule struct {
	APIGroups []string `json:"apiGroups" yaml:"apiGroups"`
	Verbs     []string `json:"verbs" yaml:"verbs"`
	Resources []string `json:"resources" yaml:"resources"`
}

Rule describe rule for service role

type Runtime

type Runtime string

Runtime is the container runtime

const (
	// Image indicates that the user has provided a docker image
	Image Runtime = "image"

	// Code indicates that the user's code isn't containerized. We need to use a custom runtime for this
	Code Runtime = "code"
)

type ScaleConfig

type ScaleConfig struct {
	Replicas    int32  `json:"replicas" yaml:"replicas"`
	MinReplicas int32  `json:"minReplicas" yaml:"minReplicas"`
	MaxReplicas int32  `json:"maxReplicas" yaml:"maxReplicas"`
	Concurrency int32  `json:"concurrency" yaml:"concurrency"`
	Mode        string `json:"mode" yaml:"mode"`
}

ScaleConfig describes the config used to scale a service

type Secret

type Secret struct {
	ID       string            `json:"id" yaml:"id"`
	Type     string            `json:"type" yaml:"type"`
	RootPath string            `json:"rootPath" yaml:"rootPath"`
	Data     map[string]string `json:"data" yaml:"data"`
}

Secret is an object for kubernetes! :|

type SecretValue

type SecretValue struct {
	Value string `json:"value" yaml:"value"`
}

SecretValue is the non-encoded secret value in the request body

type Service

type Service struct {
	ID                     string            `json:"id,omitempty" yaml:"id,omitempty"`
	Name                   string            `json:"name,omitempty" yaml:"name,omitempty"`
	ProjectID              string            `json:"projectId,omitempty" yaml:"projectId,omitempty"`
	Version                string            `json:"version,omitempty" yaml:"version,omitempty"`
	Scale                  *ScaleConfig      `json:"scale,omitempty" yaml:"scale,omitempty"`
	AutoScale              *AutoScaleConfig  `json:"autoScale,omitempty" yaml:"autoScale,omitempty"`
	Labels                 map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	Tasks                  []Task            `json:"tasks" yaml:"tasks"`
	Affinity               []Affinity        `json:"affinity,omitempty" yaml:"affinity,omitempty"`
	Whitelist              []Whitelist       `json:"whitelists" yaml:"whitelists"`
	Upstreams              []Upstream        `json:"upstreams" yaml:"upstreams"`
	StatsInclusionPrefixes string            `json:"statsInclusionPrefixes" yaml:"statsInclusionPrefixes"`
}

Service describes a service's configurations

type ServiceCallMetricHook

type ServiceCallMetricHook func(projectID string)

ServiceCallMetricHook logs apply service operation

type ServiceRequest

type ServiceRequest struct {
	IsDeploy bool     `json:"isDeploy"`
	Service  *Service `json:"service"`
}

ServiceRequest is the meta format of the meta data received from artifact store

type ServiceStatus

type ServiceStatus struct {
	ServiceID       string         `json:"serviceId" yaml:"serviceId"`
	Version         string         `json:"version" yaml:"version"`
	DesiredReplicas interface{}    `json:"desiredReplicas" yaml:"desiredReplicas"`
	Replicas        []*ReplicaInfo `json:"replicas" yaml:"replicas"`
}

ServiceStatus describes structure of service status

type SpecObject

type SpecObject struct {
	API  string            `yaml:"api"`
	Type string            `yaml:"type"`
	Meta map[string]string `yaml:"meta"`
	Spec interface{}       `yaml:"spec,omitempty"`
}

SpecObject describes the basic structure of config specifications

type Task

type Task struct {
	ID        string            `json:"id" yaml:"id"`
	Name      string            `json:"name,omitempty" yaml:"name,omitempty"`
	Ports     []Port            `json:"ports" yaml:"ports"`
	Resources Resources         `json:"resources" yaml:"resources"`
	Docker    Docker            `json:"docker" yaml:"docker"`
	Env       map[string]string `json:"env" yaml:"env"`
	Secrets   []string          `json:"secrets" yaml:"secrets"`
	Runtime   Runtime           `json:"runtime" yaml:"runtime"`
}

Task describes the configuration of a task

type Upstream

type Upstream struct {
	ProjectID string `json:"projectId" yaml:"projectId"`
	Service   string `json:"service" yaml:"service"`
}

Upstream is the upstream dependencies of this service

type Whitelist

type Whitelist struct {
	ProjectID string `json:"projectId" yaml:"projectId"`
	Service   string `json:"service" yaml:"service"`
}

Whitelist is the allowed downstream services

Jump to

Keyboard shortcuts

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