entity

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Overall status for the deployment job
	DeploymentJobStatusQueued      DeploymentJobStatus = "QUEUED"
	DeploymentJobStatusConfiguring DeploymentJobStatus = "CONFIGURING"
	DeploymentJobStatusConfigured  DeploymentJobStatus = "CONFIGURED"
	DeploymentJobStatusDeploying   DeploymentJobStatus = "DEPLOYING"
	DeploymentJobStatusDeployed    DeploymentJobStatus = "DEPLOYED"
	DeploymentJobStatusSuccess     DeploymentJobStatus = "SUCCESS"
	DeploymentJobStatusCancelled   DeploymentJobStatus = "CANCELLED"
	DeploymentJobStatusTimeOut     DeploymentJobStatus = "TIMEOUT"
	DeploymentJobStatusFailed      DeploymentJobStatus = "FAILED"

	// Host / worker specific configuring step status
	HostConfigurationStatusPending     HostConfigurationStatus = "PENDING"
	HostConfigurationStatusConfiguring HostConfigurationStatus = "CONFIGURING"
	HostConfigurationStatusSuccess     HostConfigurationStatus = "SUCCESS"
	HostConfigurationStatusFailed      HostConfigurationStatus = "FAILED"
	HostConfigurationStatusCancelled   HostConfigurationStatus = "CANCELLED"
	HostConfigurationStatusTimeOut     HostConfigurationStatus = "TIMEOUT"

	// Host / worker specific deployment (restart service, routing, etc.) step status
	HostRestartServiceStatusPending        HostRestartServiceStatus = "PENDING"
	HostRestartServiceStatusStarting       HostRestartServiceStatus = "STARTING"        // run cloudflared again
	HostRestartServiceStatusDrainTraffic   HostRestartServiceStatus = "DRAIN_TRAFFIC"   // stop cloudflared and wait; for networked service
	HostRestartServiceStatusRestarting     HostRestartServiceStatus = "RESTARTING"      // stop service, update symlink, start (systemd); for raft service
	HostRestartServiceStatusWaitReady      HostRestartServiceStatus = "WAIT_READY"      // healthcheck endpoint that includes raft get leader
	HostRestartServiceStatusRoutingTraffic HostRestartServiceStatus = "ROUTING_TRAFFIC" // run cloudflared again
	HostRestartServiceStatusSuccess        HostRestartServiceStatus = "SUCCESS"
	HostRestartServiceStatusFailed         HostRestartServiceStatus = "FAILED"
	HostRestartServiceStatusTimeOut        HostRestartServiceStatus = "TIMEOUT"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtifactdRepository

type ArtifactdRepository struct {
	URL string `json:"url"`       // in case external
	Ns  string `json:"namespace"` // in case external
	ID  string `json:"id"`
}

type BoundAddress

type BoundAddress struct {
	Host string `json:"host"`
	Port int    `json:"port"`
}

type BuildArtifact

type BuildArtifact struct {
	Ns           string          `json:"namespace" ch:"namespace"`
	Id           string          `json:"id"`
	Name         string          `json:"name" ch:"name"`
	CommitID     string          `json:"commit_id" ch:"commit_id"`
	Branch       string          `json:"branch,omitempty" ch:"branch"`
	Actor        string          `json:"actor" ch:"actor"`
	Tag          string          `json:"tag,omitempty" ch:"tag"`
	Data         json.RawMessage `json:"data" ch:"data"`
	PublishedAt  time.Time       `json:"published_at" ch:"published_at"`
	Source       string          `json:"source" ch:"source"`
	RepositoryID string          `json:"repository_id"`
	URLx         string          `json:"url"`
	OsArch       []string        `json:"os_arch" ch:"os_arch"`
	Archive      []*entity.File  `json:"archive"`
}

TODO: we can make another entity that extend this, to get "BuildArtifactByBranch" ; todo: in dg

func (*BuildArtifact) CreatedTime

func (a *BuildArtifact) CreatedTime() time.Time

func (*BuildArtifact) ID

func (a *BuildArtifact) ID() string

func (*BuildArtifact) Namespace

func (a *BuildArtifact) Namespace() string

func (*BuildArtifact) RefIDs

func (a *BuildArtifact) RefIDs() []string

func (*BuildArtifact) URL

func (a *BuildArtifact) URL() string

func (*BuildArtifact) Validate

func (a *BuildArtifact) Validate() error

func (*BuildArtifact) WithCreatedTime

func (a *BuildArtifact) WithCreatedTime(t time.Time) mycontent.Data

func (*BuildArtifact) WithEventID

func (a *BuildArtifact) WithEventID(id uint64) mycontent.VersionedData

func (*BuildArtifact) WithID

func (a *BuildArtifact) WithID(id string) mycontent.Data

func (*BuildArtifact) WithNamespace

func (a *BuildArtifact) WithNamespace(id string) mycontent.Data

func (*BuildArtifact) WithURL

func (a *BuildArtifact) WithURL(url string) mycontent.Data

type CancelJobRequest

type CancelJobRequest struct {
	Ns      string `json:"namespace"`
	Id      string `json:"id"`
	Service string `json:"service"`
}

type ClickHouseStorageConfig

type ClickHouseStorageConfig struct {
	Address string `json:"address"`
}

type CloudflareConfig

type CloudflareConfig struct {
	TunnelToken string `json:"tunnel_token"`
}

type ClusterConfiguration

type ClusterConfiguration struct {
	OS      string `json:"os"`
	Arch    string `json:"arch"`
	RaftDir string `json:"raft_dir"`
}

type ConfigureHostJob

type ConfigureHostJob struct {
	Status map[string]HostConfigurationState `json:"status"`
}

type ConfirmDeployment

type ConfirmDeployment struct {
	Message        string
	CTAButtonLabel string
}

type ContinueDeployment

type ContinueDeployment struct {
	Message    string
	TargetHost string
}

type DeploymentJob

type DeploymentJob struct {
	Ns string `json:"namespace"`
	Id string `json:"id"`

	// main status / DAG
	Status            DeploymentJobStatus `json:"status"`
	RestartServiceJob RestartServiceJob   `json:"restart_service_job"`
	ConfigureHostJob  ConfigureHostJob    `json:"configure_host_job"`

	// The request; when displaying can be omitted
	Request *SubmitDeploymentJobRequest `json:"request,omitempty"`

	// The target host in which we will deploy our service to;
	// In dragonboat lingo, this would be the Nodes, as opossed to NonVotings, Witnesses, Removed member type.
	// able to be omitted for display
	Target []Host `json:"target,omitempty"`

	RaftConfig *RaftConfig `json:"raft_config,omitempty"`

	PendingUserAction *PendingUserAction `json:"pending_user_action,omitempty"`

	Url         string     `json:"url"`
	PublishedAt time.Time  `json:"published_at"`
	FinishedAt  *time.Time `json:"finished_at,omitempty"`
}

func (*DeploymentJob) CreatedTime

func (d *DeploymentJob) CreatedTime() time.Time

func (*DeploymentJob) ID

func (d *DeploymentJob) ID() string

func (*DeploymentJob) Namespace

func (d *DeploymentJob) Namespace() string

func (*DeploymentJob) RefIDs

func (d *DeploymentJob) RefIDs() []string

func (*DeploymentJob) URL

func (d *DeploymentJob) URL() string

func (*DeploymentJob) Validate

func (d *DeploymentJob) Validate() error

func (*DeploymentJob) WithCreatedTime

func (d *DeploymentJob) WithCreatedTime(t time.Time) mycontent.Data

func (*DeploymentJob) WithID

func (d *DeploymentJob) WithID(id string) mycontent.Data

func (*DeploymentJob) WithNamespace

func (d *DeploymentJob) WithNamespace(id string) mycontent.Data

func (*DeploymentJob) WithURL

func (d *DeploymentJob) WithURL(url string) mycontent.Data

type DeploymentJobByService

type DeploymentJobByService struct {
	*DeploymentJob
}

Limitation of DG framework; if you have an entity that can indexed many way, you need to make separate struct

func (*DeploymentJobByService) RefIDs

func (d *DeploymentJobByService) RefIDs() []string

type DeploymentJobStatus

type DeploymentJobStatus string

type Env

type Env struct {
	KV
}

type Host

type Host struct {
	Ns   string `json:"namespace"`
	Host string `json:"host"`

	Architecture string `json:"architecture"`
	OS           string `json:"os"`
	FQDN         string `json:"fqdn"`

	RaftConfig RaftHostConfig `json:"raft_config"`

	PublishedAt time.Time `json:"published_at"`
	URLx        string    `json:"url"`
}

Host represents raft host configuration for a particular service

func (*Host) CreatedTime

func (a *Host) CreatedTime() time.Time

func (*Host) ID

func (a *Host) ID() string

func (*Host) Namespace

func (a *Host) Namespace() string

func (*Host) RefIDs

func (a *Host) RefIDs() []string

func (*Host) URL

func (a *Host) URL() string

func (*Host) Validate

func (a *Host) Validate() error

func (*Host) WithCreatedTime

func (a *Host) WithCreatedTime(t time.Time) mycontent.Data

func (*Host) WithID

func (a *Host) WithID(id string) mycontent.Data

func (*Host) WithNamespace

func (a *Host) WithNamespace(id string) mycontent.Data

func (*Host) WithURL

func (a *Host) WithURL(url string) mycontent.Data

type HostConfigurationState

type HostConfigurationState struct {
	ErrorMessage *string                 `json:"error_message,omitempty"`
	Status       HostConfigurationStatus `json:"status"`
	URL          string                  `json:"url,omitempty"` // url with job id to stream log from
	JobID        string                  `json:"job_id,omitempty"`
}

type HostConfigurationStatus

type HostConfigurationStatus string

type HostDeploymentJob

type HostDeploymentJob struct {
	*DeploymentJob
	Status HostRestartServiceStatus `json:"status"`
}

type HostRestartServiceState

type HostRestartServiceState struct {
	ErrorMessage *string                  `json:"error_message,omitempty"`
	Status       HostRestartServiceStatus `json:"status"`
	URL          string                   `json:"url,omitempty"` // url with job id to stream log from
	JobID        string                   `json:"job_id,omitempty"`
}

type HostRestartServiceStatus

type HostRestartServiceStatus string

type KV

type KV struct {
	Ns      string `json:"namespace"`
	Service string `json:"service"`

	Version string `json:"version"`

	Value map[string]string `json:"value"`

	PublishedAt time.Time `json:"published_at" ch:"published_at"`
	URLx        string    `json:"url"`
}

Represents key-value pair

func (*KV) CreatedTime

func (a *KV) CreatedTime() time.Time

func (*KV) ID

func (a *KV) ID() string

func (*KV) Namespace

func (a *KV) Namespace() string

func (*KV) RefIDs

func (a *KV) RefIDs() []string

func (*KV) URL

func (a *KV) URL() string

func (*KV) Validate

func (a *KV) Validate() error

func (*KV) WithCreatedTime

func (a *KV) WithCreatedTime(t time.Time) mycontent.Data

func (*KV) WithID

func (a *KV) WithID(id string) mycontent.Data

func (*KV) WithNamespace

func (a *KV) WithNamespace(ns string) mycontent.Data

func (*KV) WithURL

func (a *KV) WithURL(url string) mycontent.Data

type PendingUserAction

type PendingUserAction struct {
	// after configuration finish
	ConfirmDeployment  *ConfirmDeployment  `json:"confirm_deployment,omitempty"`
	ContinueDeployment *ContinueDeployment `json:"continue_deployment,omitempty"`
}

For front end to render the CTA, if "believe"(aka.auto confirm) is not specified

type RaftConfig

type RaftConfig struct {
	Service map[string]RaftServiceConfig `json:"service,omitempty"`
	Shards  map[uint64]RaftShardConfig   `json:"shards,omitempty"`
}

type RaftHost

type RaftHost struct {
	Id        string `json:"id,omitempty"`
	Ns        string `json:"namespace" ch:"namespace"`
	ServiceID string `json:"service_id"`

	ReplicaID      uint64 `json:"replica_id"`
	RaftAdress     string `json:"raft_address"`
	WALDir         string `json:"wal_dir"`
	NodeHostDir    string `json:"node_host_dir"`
	RTTMillisecond uint64 `json:"rtt_millisecond"`
	DeploymentID   uint64 `json:"deployment_id"`

	PublishedAt time.Time `json:"published_at" ch:"published_at"`
	URLx        string    `json:"url"`
}

RaftHost represents raft host configuration for a particular service

func (*RaftHost) CreatedTime

func (a *RaftHost) CreatedTime() time.Time

func (*RaftHost) ID

func (a *RaftHost) ID() string

func (*RaftHost) Namespace

func (a *RaftHost) Namespace() string

func (*RaftHost) RefIDs

func (a *RaftHost) RefIDs() []string

func (*RaftHost) URL

func (a *RaftHost) URL() string

func (*RaftHost) Validate

func (a *RaftHost) Validate() error

func (*RaftHost) WithCreatedTime

func (a *RaftHost) WithCreatedTime(t time.Time) mycontent.Data

func (*RaftHost) WithID

func (a *RaftHost) WithID(id string) mycontent.Data

func (*RaftHost) WithNamespace

func (a *RaftHost) WithNamespace(id string) mycontent.Data

func (*RaftHost) WithURL

func (a *RaftHost) WithURL(url string) mycontent.Data

type RaftHostConfig

type RaftHostConfig struct {
	ReplicaID       uint64 `json:"replica_id"`
	BaseWALDir      string `json:"base_wal_dir"`
	BaseNodeHostDir string `json:"base_node_host_dir"`
	RTTMillisecond  uint64 `json:"rtt_millisecond"`
}

type RaftReplica

type RaftReplica struct {
	Id        string `json:"id,omitempty"`
	Ns        string `json:"namespace" ch:"namespace"`
	ServiceID string `json:"service_id"`

	ReplicaConfig map[uint64]ReplicaConfig `json:"replica_config"`

	PublishedAt time.Time `json:"published_at" ch:"published_at"`
	URLx        string    `json:"url"`
}

RaftReplica represents raft replica configuration for a particular service

func (*RaftReplica) CreatedTime

func (a *RaftReplica) CreatedTime() time.Time

func (*RaftReplica) ID

func (a *RaftReplica) ID() string

func (*RaftReplica) Namespace

func (a *RaftReplica) Namespace() string

func (*RaftReplica) RefIDs

func (a *RaftReplica) RefIDs() []string

func (*RaftReplica) URL

func (a *RaftReplica) URL() string

func (*RaftReplica) Validate

func (a *RaftReplica) Validate() error

func (*RaftReplica) WithCreatedTime

func (a *RaftReplica) WithCreatedTime(t time.Time) mycontent.Data

func (*RaftReplica) WithID

func (a *RaftReplica) WithID(id string) mycontent.Data

func (*RaftReplica) WithNamespace

func (a *RaftReplica) WithNamespace(id string) mycontent.Data

func (*RaftReplica) WithURL

func (a *RaftReplica) WithURL(url string) mycontent.Data

type RaftServiceConfig

type RaftServiceConfig struct {
	ReplicaID    uint64 `json:"replica_id"` // convenience from host
	DeploymentID uint64 `json:"deployment_id"`
	RaftAddress  string `json:"raft_address"`
}

type RaftShardConfig

type RaftShardConfig struct {
	BootstrapHost string `json:"bootstrap_host"` // overwritten in http integration
	ShardID       uint64 `json:"shard_id"`
	ID            string `json:"id"`
	Type          string `json:"type"`
	Description   string `json:"description"`
}

type ReplicaConfig

type ReplicaConfig struct {
	ID          string          `json:"id"`
	ReplicaID   uint64          `json:"replica_id"`
	Alias       string          `json:"alias"`
	Description string          `json:"description"`
	Type        string          `json:"type"`
	Config      json.RawMessage `json:"config"`
}

type Repository

type Repository struct {
	Id          string    `json:"id"`
	Ns          string    `json:"namespace"`
	Name        string    `json:"name"`
	Source      string    `json:"source"`
	PublishedAt time.Time `json:"published_at"`
	URLx        string    `json:"url"`
}

func (*Repository) CreatedTime

func (r *Repository) CreatedTime() time.Time

func (*Repository) ID

func (r *Repository) ID() string

func (*Repository) Namespace

func (r *Repository) Namespace() string

func (*Repository) RefIDs

func (r *Repository) RefIDs() []string

func (*Repository) URL

func (r *Repository) URL() string

func (*Repository) Validate

func (r *Repository) Validate() error

func (*Repository) WithCreatedTime

func (r *Repository) WithCreatedTime(t time.Time) mycontent.Data

func (*Repository) WithID

func (r *Repository) WithID(id string) mycontent.Data

func (*Repository) WithNamespace

func (r *Repository) WithNamespace(id string) mycontent.Data

func (*Repository) WithURL

func (r *Repository) WithURL(url string) mycontent.Data

type RestartServiceJob

type RestartServiceJob struct {
	ConfirmedBy  string                             `json:"confirmed_by,omitempty"`
	CurrentOrder *uint                              `json:"current_order,omitempty"`
	HostOrder    []string                           `json:"host_order"`
	Status       map[string]HostRestartServiceState `json:"status"`
	ConfirmedAt  *time.Time                         `json:"confirmed_at,omitempty"`
}

type Routing

type Routing struct {
	Ns      string `json:"namespace"`
	Service string `json:"service"`
	Version string `json:"version"`

	CloudflareConfig *CloudflareConfig `json:"cloudflare_config,omitempty"`

	PublishedAt time.Time `json:"published_at"`
	URLx        string    `json:"url"`
}

Routing represents cloudflare config

func (*Routing) CreatedTime

func (c *Routing) CreatedTime() time.Time

func (*Routing) ID

func (c *Routing) ID() string

func (*Routing) Namespace

func (c *Routing) Namespace() string

func (*Routing) RefIDs

func (c *Routing) RefIDs() []string

func (*Routing) URL

func (c *Routing) URL() string

func (*Routing) Validate

func (c *Routing) Validate() error

func (*Routing) WithCreatedTime

func (c *Routing) WithCreatedTime(t time.Time) mycontent.Data

func (*Routing) WithID

func (c *Routing) WithID(id string) mycontent.Data

func (*Routing) WithNamespace

func (c *Routing) WithNamespace(ns string) mycontent.Data

func (*Routing) WithURL

func (c *Routing) WithURL(url string) mycontent.Data

type Secret

type Secret struct {
	KV
}

Test composition, if it's awkward in the API, might need to create new struct

type ServiceDefinition

type ServiceDefinition struct {
	Ns string `json:"namespace"`
	Id string `json:"id"`

	Name        string `json:"name"`
	Description string `json:"description"`

	Repository     ArtifactdRepository `json:"repository"`
	ExecutablePath string              `json:"executable_path"` // todo add validation

	BoundAddresses []BoundAddress `json:"bound_addresses"`

	PublishedAt time.Time `json:"published_at"`
	URLx        string    `json:"url"`
}

func (*ServiceDefinition) CreatedTime

func (a *ServiceDefinition) CreatedTime() time.Time

func (*ServiceDefinition) ID

func (a *ServiceDefinition) ID() string

func (*ServiceDefinition) Namespace

func (a *ServiceDefinition) Namespace() string

func (*ServiceDefinition) RefIDs

func (a *ServiceDefinition) RefIDs() []string

func (*ServiceDefinition) URL

func (a *ServiceDefinition) URL() string

func (*ServiceDefinition) Validate

func (a *ServiceDefinition) Validate() error

func (*ServiceDefinition) WithCreatedTime

func (a *ServiceDefinition) WithCreatedTime(t time.Time) mycontent.Data

func (*ServiceDefinition) WithID

func (a *ServiceDefinition) WithID(id string) mycontent.Data

func (*ServiceDefinition) WithNamespace

func (a *ServiceDefinition) WithNamespace(id string) mycontent.Data

func (*ServiceDefinition) WithURL

func (a *ServiceDefinition) WithURL(url string) mycontent.Data

type ServiceInstanceHost

type ServiceInstanceHost struct {
	Ns      string `json:"namespace"`
	Service string `json:"service"` // service
	Host    string `json:"host"`    // where is this deployed, the ID

	RaftConfig *RaftConfig `json:"raft_config,omitempty"`

	// current on progress deployment (if any)
	ActiveDeployment *HostDeploymentJob `json:"active_deployment,omitempty"`
	LatestDeployment *HostDeploymentJob `json:"latest_deployment,omitempty"`

	PublishedAt time.Time `json:"published_at"`
	URLx        string    `json:"url"`
}

RaftHost represents raft host configuration for a particular service

func (*ServiceInstanceHost) CreatedTime

func (a *ServiceInstanceHost) CreatedTime() time.Time

func (*ServiceInstanceHost) ID

func (a *ServiceInstanceHost) ID() string

func (*ServiceInstanceHost) Namespace

func (a *ServiceInstanceHost) Namespace() string

func (*ServiceInstanceHost) RefIDs

func (a *ServiceInstanceHost) RefIDs() []string

func (*ServiceInstanceHost) URL

func (a *ServiceInstanceHost) URL() string

func (*ServiceInstanceHost) Validate

func (a *ServiceInstanceHost) Validate() error

func (*ServiceInstanceHost) WithCreatedTime

func (a *ServiceInstanceHost) WithCreatedTime(t time.Time) mycontent.Data

func (*ServiceInstanceHost) WithID

func (a *ServiceInstanceHost) WithID(id string) mycontent.Data

func (*ServiceInstanceHost) WithNamespace

func (a *ServiceInstanceHost) WithNamespace(id string) mycontent.Data

func (*ServiceInstanceHost) WithURL

func (a *ServiceInstanceHost) WithURL(url string) mycontent.Data

type StorageConfiguration

type StorageConfiguration struct {
	Clickhouse ClickHouseStorageConfig `json:"clickhouse"`
}

type SubmitDeploymentJobRequest

type SubmitDeploymentJobRequest struct {
	Ns      string            `json:"namespace"`
	Service ServiceDefinition `json:"service"`
	Id      string            `json:"id"`

	BuildVersion  uint64 `json:"build_version"`
	SecretVersion uint64 `json:"secret_version"`
	EnvVersion    uint64 `json:"env_version"`

	// optional: lookup configure cloudflare routing
	RoutingVersion *uint64 `json:"routing_version,omitempty"`

	// TODO: List of hosts to deploy to; for first time deployment
	TargetHosts []Host `json:"target_hosts,omitempty"`

	// Register (new) replica at the deployment time.
	RaftShard        map[uint64]RaftShardConfig `json:"raft_shard,omitempty"`
	RaftPort         uint16                     `json:"raft_port"`
	RaftPortMapping  map[string]uint16          `json:"raft_port_mapping,omitempty"` // optional if at each host, the port is different
	RaftDeploymentID uint64                     `json:"raft_deployment_id"`

	ModifyKey *string `json:"-"` // hidden; TODO: to be nice, to lock, only the one who have this key can modify the state.

	TimeoutSeconds *uint32 `json:"timeout_seconds,omitempty"`

	IsBelieve   bool      `json:"is_believe"`
	Url         string    `json:"url"`
	PublishedAt time.Time `json:"published_at"`
}

Jump to

Keyboard shortcuts

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