entities

package
v0.0.0-...-149ea5c Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const JobStateError = "error"

JobStateError - job state error

View Source
const JobStateSuccess = "success"

JobStateSuccess - job state success

View Source
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

func PublicPortExists(port uint32, params map[string]interface{}) bool

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) Create

func (a *Application) Create() error

Create creates user in db

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

func (*Application) Save

func (a *Application) Save() error

Save saves user entity in db

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

func CreateJob

func CreateJob(user *User) (job *Job, err error)

CreateJob creates new job with "working" state

func GetJob

func GetJob(id string) (*Job, error)

GetJob return job ny id

func (*Job) SetState

func (j *Job) SetState(state string, result interface{}) error

SetState sets state and result for current job

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

func GetService(params map[string]interface{}) (*Service, error)

GetService return service if it exists

func GetServices

func GetServices(params map[string]interface{}) ([]Service, error)

GetServices returns services by filters

func (*Service) AddServiceStatus

func (s *Service) AddServiceStatus(status ServiceStatusStruct)

AddServiceStatus -add service task status to list

func (*Service) Create

func (s *Service) Create() error

Create creates user in db

func (*Service) Delete

func (s *Service) Delete() error

Delete - removed entity from database

func (*Service) LoadApplication

func (s *Service) LoadApplication() error

LoadApplication loads application to Application field

func (*Service) Save

func (s *Service) Save() error

Save saves user entity in db

func (*Service) UpdateParams

func (s *Service) UpdateParams(newService *Service) (errors []string)

UpdateParams - updates service entity with other service entity

type ServiceEnvVariable

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

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

func GenerateToken

func GenerateToken() *Token

GenerateToken generated new token

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 GetUser

func GetUser(email string) (*User, error)

GetUser returns User object from db

func GetUserByToken

func GetUserByToken(token string) (*User, error)

GetUserByToken returns user by associated token

func GetUsers

func GetUsers(params bson.M) ([]User, error)

GetUsers returns all users

func (*User) Create

func (u *User) Create() error

Create creates user in db

func (*User) GetApplications

func (u *User) GetApplications() ([]Application, error)

GetApplications return user's applications

func (*User) Save

func (u *User) Save() error

Save saves user entity in db

Jump to

Keyboard shortcuts

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