framework

package
v0.0.0-...-24596cf Latest Latest
Warning

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

Go to latest
Published: May 19, 2016 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LayerZone = iota
	LayerCluster
	LayerDataCenter
	LayerStack
)
View Source
const (
	ConfigStack = iota
	ConfigDataCenter
	ConfigCluster
	ConfigZone
)

Variables

View Source
var ApplicationStatuses = map[ApplicationStatus]string{
	ApplicationStatusStaging: "STAGING",
	ApplicationStatusRunning: "RUNNING",
	ApplicationStatusFailed:  "FAILED",
}
View Source
var ErrApplicationDoesNotExist = errors.New("Application does not exist")
View Source
var ErrApplicationInvalidCPU = errors.New("Invalid application CPU")
View Source
var ErrApplicationInvalidInstances = errors.New("Invalid number of application instances: supported are numbers greater than zero and 'all'")
View Source
var ErrApplicationInvalidMem = errors.New("Invalid application Mem")
View Source
var ErrApplicationNoID = errors.New("No application ID")
View Source
var ErrApplicationNoTaskRunner = errors.New("No task runner available for application")
View Source
var ErrApplicationNoType = errors.New("No application type")
View Source
var ErrHealthcheckNotPassing = errors.New("Task healthcheck is not passing")
View Source
var ErrStackStateDoesNotExist = errors.New("Stack state does not exist")
View Source
var ErrStackStateExists = errors.New("Stack state already exists")
View Source
var ErrTaskNotRunning = errors.New("Task is not running")
View Source
var MesosTaskRunners map[string]MesosTaskRunner
View Source
var TaskRunners map[string]TaskRunner

Functions

func MapSliceToMap

func MapSliceToMap(slice yaml.MapSlice) map[string]string

func NewStorage

func NewStorage(storage string) (utils.Storage, error)

func UUID

func UUID() string

Types

type Application

type Application struct {
	sync.RWMutex
	Type                string            `yaml:"type,omitempty"`
	ID                  string            `yaml:"id,omitempty"`
	Version             string            `yaml:"version,omitempty"`
	Cpu                 float64           `yaml:"cpu,omitempty"`
	Mem                 float64           `yaml:"mem,omitempty"`
	Ports               []int             `yaml:"ports,omitempty"`
	Instances           string            `yaml:"instances,omitempty"`
	Constraints         [][]string        `yaml:"constraints,omitempty"`
	User                string            `yaml:"user,omitempty"`
	Healthcheck         string            `yaml:"healthcheck,omitempty"`
	LaunchCommand       string            `yaml:"launch_command,omitempty"`
	Args                []string          `yaml:"args,omitempty"`
	Env                 map[string]string `yaml:"env,omitempty"`
	ArtifactURLs        []string          `yaml:"artifact_urls,omitempty"`
	AdditionalArtifacts []string          `yaml:"additional_artifacts,omitempty"`
	Scheduler           map[string]string `yaml:"scheduler,omitempty"`
	Tasks               yaml.MapSlice     `yaml:"tasks,omitempty"`
	Dependencies        []string          `yaml:"dependencies,omitempty"`
	Docker              *Docker           `yaml:"docker,omitempty"`
	StartTime           string            `yaml:"start_time,omitempty"`
	TimeSchedule        string            `yaml:"time_schedule,omitempty"`

	BeforeScheduler []string `yaml:"before_scheduler,omitempty"`
	AfterScheduler  []string `yaml:"after_scheduler,omitempty"`
	BeforeTask      []string `yaml:"before_task,omitempty"`
	AfterTask       []string `yaml:"after_task,omitempty"`
	AfterTasks      []string `yaml:"after_tasks,omitempty"`
}

func (*Application) GetConstraints

func (a *Application) GetConstraints() map[string][]constraints.Constraint

func (*Application) GetInstances

func (a *Application) GetInstances(mesos MesosState) int

func (*Application) IsDependencySatisfied

func (a *Application) IsDependencySatisfied(runningApps map[string]ApplicationStatus) bool

func (*Application) Run

func (a *Application) Run(context *RunContext, maxWait int) error

func (*Application) String

func (a *Application) String() string

func (*Application) Validate

func (a *Application) Validate() error

type ApplicationRunStatus

type ApplicationRunStatus struct {
	Application *Application
	Error       error
}

func NewApplicationRunStatus

func NewApplicationRunStatus(application *Application, err error) *ApplicationRunStatus

type ApplicationStatus

type ApplicationStatus int
const (
	ApplicationStatusStaging ApplicationStatus = iota
	ApplicationStatusRunning
	ApplicationStatusFailed
)

type CassandraStateStorage

type CassandraStateStorage struct {
	// contains filtered or unexported fields
}

func NewCassandraStateStorage

func NewCassandraStateStorage(connection *gocql.Session, keyspace string) (*CassandraStateStorage, error)

func (*CassandraStateStorage) GetStackState

func (css *CassandraStateStorage) GetStackState(name string, zone string) (*StackState, error)

func (*CassandraStateStorage) SaveApplicationStatus

func (css *CassandraStateStorage) SaveApplicationStatus(stack string, zone string, applicationName string, status ApplicationStatus) error

func (*CassandraStateStorage) SaveStackStatus

func (css *CassandraStateStorage) SaveStackStatus(name string, zone string, status StackStatus) error

func (*CassandraStateStorage) SaveStackVariables

func (css *CassandraStateStorage) SaveStackVariables(stack string, zone string, variables *Variables) error

type CassandraStorage

type CassandraStorage struct {
	// contains filtered or unexported fields
}

func (*CassandraStorage) GetAll

func (cs *CassandraStorage) GetAll() ([]*Stack, error)

func (*CassandraStorage) GetLayer

func (cs *CassandraStorage) GetLayer(name string) (*Layer, error)

func (*CassandraStorage) GetLayersStack

func (cs *CassandraStorage) GetLayersStack(name string) (Merger, error)

func (*CassandraStorage) GetStack

func (cs *CassandraStorage) GetStack(name string) (*Stack, error)

func (*CassandraStorage) GetStackRunner

func (cs *CassandraStorage) GetStackRunner(name string) (Runner, error)

func (*CassandraStorage) Init

func (cs *CassandraStorage) Init() error

func (*CassandraStorage) RemoveStack

func (cs *CassandraStorage) RemoveStack(stack string, force bool) error

func (*CassandraStorage) StoreStack

func (cs *CassandraStorage) StoreStack(stack *Stack) error

type CassandraUserStorage

type CassandraUserStorage struct {
	// contains filtered or unexported fields
}

func NewCassandraUserStorage

func NewCassandraUserStorage(connection *gocql.Session, keyspace string) (*CassandraUserStorage, string, error)

func (CassandraUserStorage) CheckKey

func (cus CassandraUserStorage) CheckKey(name string, key string) (bool, error)

func (CassandraUserStorage) CreateUser

func (cus CassandraUserStorage) CreateUser(name string, role UserRole) (string, error)

func (CassandraUserStorage) GetUser

func (cus CassandraUserStorage) GetUser(name string) (*User, error)

func (CassandraUserStorage) Init

func (cus CassandraUserStorage) Init() (string, error)

func (CassandraUserStorage) IsAdmin

func (cus CassandraUserStorage) IsAdmin(name string) (bool, error)

func (CassandraUserStorage) RefreshToken

func (cus CassandraUserStorage) RefreshToken(name string) (string, error)

func (CassandraUserStorage) SaveUser

func (cus CassandraUserStorage) SaveUser(user User) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(host string) *Client

func (*Client) CreateLayer

func (c *Client) CreateLayer(data *CreateLayerRequest) error

func (*Client) CreateStack

func (c *Client) CreateStack(data *CreateStackRequest) error

func (*Client) CreateUser

func (c *Client) CreateUser(data *CreateUserRequest) (string, error)

func (*Client) GetStack

func (c *Client) GetStack(data *GetStackRequest) (*Stack, error)

func (*Client) List

func (c *Client) List() ([]string, error)

func (*Client) Ping

func (c *Client) Ping() error

func (*Client) RefreshToken

func (c *Client) RefreshToken(data *RefreshTokenRequest) (string, error)

func (*Client) RemoveScheduled

func (c *Client) RemoveScheduled(data *RemoveScheduledRequest) (string, error)

func (*Client) RemoveStack

func (c *Client) RemoveStack(data *RemoveStackRequest) error

func (*Client) Run

func (c *Client) Run(data *RunRequest) error

func (*Client) Scheduled

func (c *Client) Scheduled() ([]*ScheduledTask, error)

type CreateLayerRequest

type CreateLayerRequest struct {
	Stackfile string `json:"stackfile"`
	Layer     string `json:"layer"`
	Parent    string `json:"parent"`
}

type CreateStackRequest

type CreateStackRequest struct {
	Stackfile string `json:"stackfile"`
}

type CreateUserRequest

type CreateUserRequest struct {
	Name string `json:"name"`
	Role string `json:"role"`
}

type CronScheduler

type CronScheduler interface {
	AddFunc(string, func()) (int64, error)
	DeleteJob(int64)
	Entries() []*cron.Entry
}

type Docker

type Docker struct {
	ForcePullImage bool                 `yaml:"force_pull_image,omitempty"`
	Image          string               `yaml:"image,omitempty"`
	Network        string               `yaml:"network,omitempty"`
	Parameters     map[string]string    `yaml:"parameters,omitempty"`
	PortMappings   []*DockerPortMapping `yaml:"port_mappings,omitempty"`
	Privileged     bool                 `yaml:"privileged,omitempty"`
	Volumes        []*DockerVolume      `yaml:"volumes,omitempty"`
}

func (*Docker) MarathonContainer

func (d *Docker) MarathonContainer() *marathon.Container

type DockerPortMapping

type DockerPortMapping struct {
	ContainerPort int    `yaml:"container_port,omitempty"`
	HostPort      int    `yaml:"host_port"`
	ServicePort   int    `yaml:"service_port,omitempty"`
	Protocol      string `yaml:"protocol"`
}

func (*DockerPortMapping) Marathon

func (dpm *DockerPortMapping) Marathon() *marathon.PortMapping

type DockerVolume

type DockerVolume struct {
	ContainerPath string `yaml:"container_path,omitempty"`
	HostPath      string `yaml:"host_path,omitempty"`
	Mode          string `yaml:"mode,omitempty"`
}

func (*DockerVolume) Marathon

func (dv *DockerVolume) Marathon() *marathon.Volume

type FrameworkStorage

type FrameworkStorage struct {
	FrameworkID      string
	BootstrapContext *Variables
	// contains filtered or unexported fields
}

func NewFrameworkStorage

func NewFrameworkStorage(storage string) (*FrameworkStorage, error)

func (*FrameworkStorage) Load

func (s *FrameworkStorage) Load()

func (*FrameworkStorage) Save

func (s *FrameworkStorage) Save()

type GetStackRequest

type GetStackRequest struct {
	Name string `json:"name"`
}

type InMemoryStateStorage

type InMemoryStateStorage struct {
	// contains filtered or unexported fields
}

func NewInMemoryStateStorage

func NewInMemoryStateStorage() *InMemoryStateStorage

func (*InMemoryStateStorage) GetStackState

func (s *InMemoryStateStorage) GetStackState(stack string, zone string) (*StackState, error)

func (*InMemoryStateStorage) SaveApplicationStatus

func (s *InMemoryStateStorage) SaveApplicationStatus(stack string, zone string, applicationName string, status ApplicationStatus) error

func (*InMemoryStateStorage) SaveStackStatus

func (s *InMemoryStateStorage) SaveStackStatus(name string, zone string, status StackStatus) error

func (*InMemoryStateStorage) SaveStackVariables

func (s *InMemoryStateStorage) SaveStackVariables(stack string, zone string, variables *Variables) error

type InMemoryStorage

type InMemoryStorage struct {
	// contains filtered or unexported fields
}

func NewInMemoryStorage

func NewInMemoryStorage() *InMemoryStorage

func (*InMemoryStorage) GetAll

func (s *InMemoryStorage) GetAll() ([]*Stack, error)

func (*InMemoryStorage) GetLayer

func (s *InMemoryStorage) GetLayer(name string) (*Layer, error)

func (*InMemoryStorage) GetLayersStack

func (s *InMemoryStorage) GetLayersStack(name string) (Merger, error)

func (*InMemoryStorage) GetStack

func (s *InMemoryStorage) GetStack(name string) (*Stack, error)

func (*InMemoryStorage) GetStackRunner

func (s *InMemoryStorage) GetStackRunner(name string) (Runner, error)

func (*InMemoryStorage) Init

func (s *InMemoryStorage) Init() error

func (*InMemoryStorage) RemoveStack

func (s *InMemoryStorage) RemoveStack(name string, force bool) error

func (*InMemoryStorage) StoreStack

func (s *InMemoryStorage) StoreStack(stack *Stack) error

type Layer

type Layer struct {
	Level int
	Stack *Stack
}

func NewCluster

func NewCluster(stack *Stack) *Layer

func NewDataCenter

func NewDataCenter(stack *Stack) *Layer

func NewLayer

func NewLayer(stack *Stack) *Layer

func NewZone

func NewZone(stack *Stack) *Layer

func (*Layer) Merge

func (l *Layer) Merge(other *Layer) error

you can merge only lower level layers Stack.Merge(DataCenter) DataCenter.Merge(Cluster)) Cluster.Merge(Zone)

type Merger

type Merger interface {
	Merge(*Stack)
	GetRunner() Runner
}

type MesosClusterState

type MesosClusterState struct {
	ActivatedSlaves float64 `json:"activated_slaves"`
	Slaves          []Slave `json:"slaves"`
	// contains filtered or unexported fields
}

TODO extend this struct when necessary

func NewMesosClusterState

func NewMesosClusterState(master string) *MesosClusterState

func (*MesosClusterState) GetActivatedSlaves

func (ms *MesosClusterState) GetActivatedSlaves() int

func (*MesosClusterState) GetSlaves

func (ms *MesosClusterState) GetSlaves() []Slave

func (*MesosClusterState) String

func (ms *MesosClusterState) String() string

func (*MesosClusterState) Update

func (ms *MesosClusterState) Update() error

type MesosState

type MesosState interface {
	Update() error
	GetActivatedSlaves() int
	GetSlaves() []Slave
}

type MesosTaskRunner

type MesosTaskRunner interface {
	ScheduleApplication(*Application, MesosState, CronScheduler) (int64, <-chan *ApplicationRunStatus)
	DeleteSchedule(int64, CronScheduler)
	StageApplication(application *Application, mesos MesosState) <-chan *ApplicationRunStatus
	ResourceOffer(driver scheduler.SchedulerDriver, offer *mesos.Offer) (string, error)
	StatusUpdate(driver scheduler.SchedulerDriver, status *mesos.TaskStatus) bool
}

type NoopUserStorage

type NoopUserStorage struct{}

func (*NoopUserStorage) CheckKey

func (s *NoopUserStorage) CheckKey(string, string) (bool, error)

func (*NoopUserStorage) CreateUser

func (s *NoopUserStorage) CreateUser(string, UserRole) (string, error)

func (*NoopUserStorage) GetUser

func (s *NoopUserStorage) GetUser(string) (*User, error)

func (*NoopUserStorage) IsAdmin

func (s *NoopUserStorage) IsAdmin(string) (bool, error)

func (*NoopUserStorage) RefreshToken

func (s *NoopUserStorage) RefreshToken(string) (string, error)

func (*NoopUserStorage) SaveUser

func (s *NoopUserStorage) SaveUser(User) error

type RefreshTokenRequest

type RefreshTokenRequest struct {
	Name string `json:"name"`
}

type RemoveScheduledRequest

type RemoveScheduledRequest struct {
	ID int64 `json:"id"`
}

type RemoveStackRequest

type RemoveStackRequest struct {
	Name  string `json:"name"`
	Force bool   `json:"force"`
}

type RunContext

type RunContext struct {
	StackName    string
	Zone         string
	Variables    *Variables
	Marathon     marathon.Marathon
	Scheduler    Scheduler
	StateStorage StateStorage
}

func NewRunContext

func NewRunContext(variables *Variables) *RunContext

type RunRequest

type RunRequest struct {
	Name             string            `json:"name"`
	Zone             string            `json:"zone"`
	MaxWait          int               `json:"maxwait"`
	Variables        map[string]string `json:"variables"`
	SkipApplications []string          `json:"skip"`
}

type Runner

type Runner interface {
	Run(*RunRequest, *RunContext) error
	GetStack() *Stack
}

type ScheduledTask

type ScheduledTask struct {
	ID           int64  `json:"id"`
	Name         string `json:"name"`
	StartTime    string `json:"start_time"`
	TimeSchedule string `json:"time_schedule"`
}

type Scheduler

type Scheduler interface {
	Start() error
	RunApplication(application *Application) <-chan *ApplicationRunStatus
	GetMesosState() MesosState
	GetScheduledTasks() []*ScheduledTask
	RemoveScheduled(int64) bool
}

type SchedulerConfig

type SchedulerConfig struct {
	Master          string
	Storage         *FrameworkStorage
	User            string
	FrameworkName   string
	FrameworkRole   string
	FailoverTimeout time.Duration
}

func NewSchedulerConfig

func NewSchedulerConfig() *SchedulerConfig

type Slave

type Slave struct {
	Active     bool                   `json:"active"`
	Attributes map[string]string      `json:"attributes"`
	Hostname   string                 `json:"hostname"`
	ID         string                 `json:"id"`
	PID        string                 `json:"pid"`
	Resources  map[string]interface{} `json:"resources"`
}

func (*Slave) Attribute

func (s *Slave) Attribute(name string) string

type Stack

type Stack struct {
	Namespace    string
	Name         string                  `yaml:"name,omitempty"`
	From         string                  `yaml:"from,omitempty"`
	Applications map[string]*Application `yaml:"applications,omitempty"`
	Layer        int
}

func UnmarshalStack

func UnmarshalStack(yml []byte) (*Stack, error)

func (*Stack) GetApplications

func (s *Stack) GetApplications() map[string]*Application

func (*Stack) GetRunner

func (s *Stack) GetRunner() Runner

func (*Stack) GetStack

func (s *Stack) GetStack() *Stack

func (Stack) ID

func (s Stack) ID() string

func (*Stack) Merge

func (s *Stack) Merge(child *Stack)

func (*Stack) Run

func (s *Stack) Run(request *RunRequest, context *RunContext) error

func (*Stack) String

func (s *Stack) String() string

func (*Stack) Validate

func (s *Stack) Validate() error

type StackDeployScheduler

type StackDeployScheduler struct {
	*SchedulerConfig

	Cron *cron.Cron
	// contains filtered or unexported fields
}

func NewScheduler

func NewScheduler(config *SchedulerConfig) *StackDeployScheduler

func (*StackDeployScheduler) Disconnected

func (*StackDeployScheduler) Error

func (s *StackDeployScheduler) Error(driver scheduler.SchedulerDriver, message string)

func (*StackDeployScheduler) ExecutorLost

func (s *StackDeployScheduler) ExecutorLost(driver scheduler.SchedulerDriver, executor *mesos.ExecutorID, slave *mesos.SlaveID, status int)

func (*StackDeployScheduler) FrameworkMessage

func (s *StackDeployScheduler) FrameworkMessage(driver scheduler.SchedulerDriver, executor *mesos.ExecutorID, slave *mesos.SlaveID, message string)

func (*StackDeployScheduler) GetMesosState

func (s *StackDeployScheduler) GetMesosState() MesosState

func (*StackDeployScheduler) GetScheduledTasks

func (s *StackDeployScheduler) GetScheduledTasks() []*ScheduledTask

func (*StackDeployScheduler) OfferRescinded

func (s *StackDeployScheduler) OfferRescinded(driver scheduler.SchedulerDriver, id *mesos.OfferID)

func (*StackDeployScheduler) Registered

func (s *StackDeployScheduler) Registered(driver scheduler.SchedulerDriver, id *mesos.FrameworkID, master *mesos.MasterInfo)

func (*StackDeployScheduler) RemoveScheduled

func (s *StackDeployScheduler) RemoveScheduled(id int64) bool

func (*StackDeployScheduler) Reregistered

func (s *StackDeployScheduler) Reregistered(driver scheduler.SchedulerDriver, master *mesos.MasterInfo)

func (*StackDeployScheduler) ResourceOffers

func (s *StackDeployScheduler) ResourceOffers(driver scheduler.SchedulerDriver, offers []*mesos.Offer)

func (*StackDeployScheduler) RunApplication

func (s *StackDeployScheduler) RunApplication(application *Application) <-chan *ApplicationRunStatus

func (*StackDeployScheduler) Shutdown

func (*StackDeployScheduler) SlaveLost

func (s *StackDeployScheduler) SlaveLost(driver scheduler.SchedulerDriver, slave *mesos.SlaveID)

func (*StackDeployScheduler) Start

func (s *StackDeployScheduler) Start() error

func (*StackDeployScheduler) StatusUpdate

func (s *StackDeployScheduler) StatusUpdate(driver scheduler.SchedulerDriver, status *mesos.TaskStatus)

type StackDeployServer

type StackDeployServer struct {
	// contains filtered or unexported fields
}

func NewApiServer

func NewApiServer(api string, marathonClient marathon.Marathon, globalVariables map[string]string, storage Storage, userStorage UserStorage, stateStorage StateStorage,
	scheduler Scheduler) *StackDeployServer

func (*StackDeployServer) Admin

func (ts *StackDeployServer) Admin(handler http.HandlerFunc) http.HandlerFunc

Middleware for admin role check

func (*StackDeployServer) Auth

Middleware for authentication check

func (*StackDeployServer) CreateLayerHandler

func (ts *StackDeployServer) CreateLayerHandler(w http.ResponseWriter, r *http.Request)

func (*StackDeployServer) CreateStackHandler

func (ts *StackDeployServer) CreateStackHandler(w http.ResponseWriter, r *http.Request)

func (*StackDeployServer) CreateUserHandler

func (ts *StackDeployServer) CreateUserHandler(w http.ResponseWriter, r *http.Request)

func (*StackDeployServer) GetStackHandler

func (ts *StackDeployServer) GetStackHandler(w http.ResponseWriter, r *http.Request)

func (*StackDeployServer) HealthHandler

func (ts *StackDeployServer) HealthHandler(w http.ResponseWriter, r *http.Request)

func (*StackDeployServer) ListHandler

func (ts *StackDeployServer) ListHandler(w http.ResponseWriter, r *http.Request)

func (*StackDeployServer) RefreshTokenHandler

func (ts *StackDeployServer) RefreshTokenHandler(w http.ResponseWriter, r *http.Request)

func (*StackDeployServer) RemoveScheduledHandler

func (ts *StackDeployServer) RemoveScheduledHandler(w http.ResponseWriter, r *http.Request)

func (*StackDeployServer) RemoveStackHandler

func (ts *StackDeployServer) RemoveStackHandler(w http.ResponseWriter, r *http.Request)

func (*StackDeployServer) RunHandler

func (ts *StackDeployServer) RunHandler(w http.ResponseWriter, r *http.Request)

func (*StackDeployServer) ScheduledHandler

func (ts *StackDeployServer) ScheduledHandler(w http.ResponseWriter, r *http.Request)

func (*StackDeployServer) Start

func (ts *StackDeployServer) Start()

type StackState

type StackState struct {
	Name         string
	Zone         string
	Status       StackStatus
	Variables    *Variables
	Applications map[string]ApplicationStatus
}

type StackStatus

type StackStatus int
const (
	StackStatusStaging StackStatus = iota
	StackStatusRunning
	StackStatusFailed
)

type StateStorage

type StateStorage interface {
	SaveStackStatus(name string, zone string, status StackStatus) error
	SaveApplicationStatus(stack string, zone string, applicationName string, status ApplicationStatus) error
	SaveStackVariables(stack string, zone string, variables *Variables) error
	GetStackState(name string, zone string) (*StackState, error)
}

type Storage

type Storage interface {
	GetAll() ([]*Stack, error)
	GetStack(string) (*Stack, error)
	GetStackRunner(string) (Runner, error)
	StoreStack(*Stack) error
	RemoveStack(string, bool) error
	Init() error
	GetLayersStack(string) (Merger, error)
}

func NewCassandraStorage

func NewCassandraStorage(addresses []string, keyspace string, proto int) (Storage, *gocql.Session, error)

func NewCassandraStorageRetryBackoff

func NewCassandraStorageRetryBackoff(cluster []string, keyspace string, retries int, backoff time.Duration, proto int) (Storage, *gocql.Session, error)

type TaskRunner

type TaskRunner interface {
	FillContext(context *Variables, application *Application, task marathon.Task) error
	RunTask(context *Variables, application *Application, task map[string]string) error
}

type User

type User struct {
	Name string   `json:"name"`
	Key  string   `json:"key"`
	Role UserRole `json:"role"`
}

func (*User) UnmarshalJSON

func (u *User) UnmarshalJSON(data []byte) error

type UserRole

type UserRole int
const (
	UserAdmin   UserRole = 0
	UserRegular UserRole = 1
)

type UserStorage

type UserStorage interface {
	SaveUser(User) error
	GetUser(string) (*User, error)
	CheckKey(string, string) (bool, error)
	IsAdmin(string) (bool, error)
	CreateUser(string, UserRole) (string, error)
	RefreshToken(string) (string, error)
}

type Variables

type Variables struct {
	// contains filtered or unexported fields
}

func NewVariables

func NewVariables() *Variables

func (*Variables) All

func (v *Variables) All() map[string]string

func (*Variables) Get

func (v *Variables) Get(key string) (string, error)

func (*Variables) MarshalJSON

func (v *Variables) MarshalJSON() ([]byte, error)

func (*Variables) MustGet

func (v *Variables) MustGet(key string) string

func (*Variables) SetArbitraryVariable

func (v *Variables) SetArbitraryVariable(key string, value string)

func (*Variables) SetGlobalVariable

func (v *Variables) SetGlobalVariable(key string, value string)

func (*Variables) SetStackVariable

func (v *Variables) SetStackVariable(key string, value string)

func (*Variables) String

func (v *Variables) String() string

func (*Variables) UnmarshalJSON

func (v *Variables) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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