Documentation ¶
Index ¶
Constants ¶
const ( // NodeAvailabilityActive ACTIVE NodeAvailabilityActive = "active" // NodeAvailabilityPause PAUSE NodeAvailabilityPause = "pause" // NodeAvailabilityDrain DRAIN NodeAvailabilityDrain = "drain" // NodeStateUnknown UNKNOWN NodeStateUnknown = "unknown" // NodeStateDown DOWN NodeStateDown = "down" // NodeStateReady READY NodeStateReady = "ready" // NodeStateDisconnected DISCONNECTED NodeStateDisconnected = "disconnected" )
const JobStateError = "error"
JobStateError - job state error
const JobStateSuccess = "success"
JobStateSuccess - job state success
const JobStateWorking = "working"
JobStateWorking - job state working
Variables ¶
This section is empty.
Functions ¶
func MustGetPublicPort ¶
func MustGetPublicPort() uint32
MustGetPublicPort returns random free public port in 10000 - 60000
func PublicPortExists ¶
PublicPortExists checks if public port exists
Types ¶
type Application ¶
type Application struct { ID string `json:"id" bson:"_id,omitempty"` Name string `json:"name"` UserID string `json:"-" bson:"user_id"` Services []Service `json:"services,omitempty" bson:"-"` ServiceIDS []string `json:"service_ids,omitempty" bson:"-"` }
Application describes application entity
func GetApplication ¶
func GetApplication(params map[string]interface{}) (*Application, error)
GetApplication return application if it exists
func GetApplications ¶
func GetApplications(params map[string]interface{}) ([]Application, error)
GetApplications returns applications by request
func (*Application) Delete ¶
func (a *Application) Delete() error
Delete - deletes applications and it's services
func (*Application) GetServices ¶
func (a *Application) GetServices() ([]Service, error)
GetServices returns application services
func (*Application) LoadServices ¶
func (a *Application) LoadServices()
LoadServices retrieves services associated with application
type FrontendEndpoint ¶
type FrontendEndpoint struct { Domain string `json:"domain" bson:"domain"` InternalPort uint32 `json:"internal_port" bson:"internal_port"` ExternalPort uint32 `json:"external_port" bsin:"external_port"` Disabled bool `json:"disabled" bson:"disabled"` }
FrontendEndpoint - represents frontend endpoint
type Job ¶
type Job struct { ID string `json:"id" bson:"_id"` UserID string `json:"_" bson:"user_id"` State string `json:"state" bson:"state"` Result interface{} `json:"result" bson:"result"` StartedAt time.Time `json:"started_at" bson:"started_at"` FinishedAt time.Time `json:"finished_at" bson:"finished_at"` }
Job struct
type Node ¶
type Node struct { ID string `json:"id"` Addr string `json:"addr"` Hostname string `json:"hostname"` Availability string `json:"availability"` State string `json:"state"` Role string `json:"role"` NanoCPUs int64 `json:"nano_cpus"` MemoryBytes int64 `json:"memory_bytes"` EngineVersion string `json:"engine_version"` }
Node represents swarm node
type Service ¶
type Service struct { ID string `bson:"_id,omitempty" json:"id"` Name string `json:"name"` Image string `json:"image"` Command string `json:"command"` NSName string `json:"ns_name" bson:"ns_name"` Replicas *uint64 `json:"replicas"` Parallelism uint64 `json:"parallelism"` EnvVariables []ServiceEnvVariable `json:"env" bson:"env_vars"` PublishedPorts []ServicePublishedPort `json:"published_ports" bson:"published_ports"` FrontendEndpoints []FrontendEndpoint `json:"frontend_endpoints" bson:"frontend_endpoints"` ApplicationID string `bson:"application_id,omitempty" json:"application_id,omitempty"` UserID string `bson:"user_id" json:"-"` Volumes []ServiceVolume `bson:"volumes" json:"volumes"` Application Application `bson:"-" json:"-"` Status []ServiceStatusStruct `bson:"-" json:"status,omitempty"` }
Service describes service entity
func GetService ¶
GetService return service if it exists
func GetServices ¶
GetServices returns services by filters
func (*Service) AddServiceStatus ¶
func (s *Service) AddServiceStatus(status ServiceStatusStruct)
AddServiceStatus -add service task status to list
func (*Service) LoadApplication ¶
LoadApplication loads application to Application field
func (*Service) UpdateParams ¶
UpdateParams - updates service entity with other service entity
type ServiceEnvVariable ¶
ServiceEnvVariable - represents name value struct
type ServicePublishedPort ¶
type ServicePublishedPort struct { Internal uint32 `json:"internal"` External uint32 `json:"external"` Protocol string `json:"protocol"` Disabled bool `json:"disabled"` }
ServicePublishedPort - represents serivce publishing port
type ServiceStatusStruct ¶
type ServiceStatusStruct struct { ReplicaID string `json:"replica_id"` Node string `json:"node"` Status string `json:"status"` Timestamp time.Time `json:"timestamp"` Error string `json:"error"` }
ServiceStatusStruct represents current service's task state
type ServiceVolume ¶
type ServiceVolume struct { Service string `json:"service" bson:"service"` Backend string `json:"backend,omitempty" bson:"backend"` AppWide bool `json:"app_wide,omitempty" bson:"app_wide"` Size int64 `json:"size,omitempty" bson:"-"` }
ServiceVolume - represents mounted volume
type Token ¶
type Token struct { Token string `json:"token"` User *User `json:"user" bson:"-"` LastUsed time.Time `json:"last_used,omitempty"` }
Token represent auth token for User
type User ¶
type User struct { ID string `json:"id" bson:"_id,omitempty"` Email string `json:"email"` Password string `json:"-"` Tokens []Token `json:"-"` }
User describes service entity
func GetUserByToken ¶
GetUserByToken returns user by associated token
func (*User) GetApplications ¶
func (u *User) GetApplications() ([]Application, error)
GetApplications return user's applications