medias

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2018 License: MIT Imports: 14 Imported by: 3

Documentation

Overview

Package medias

Provide API to access medias information

Schemes: http, https

swagger:meta

Index

Constants

View Source
const MEDIAS_CONFIG_FILENAME string = "medias.json"
View Source
const MEDIAS_CONFIG_PATH string = "data"

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	LastID int     `json:"lastid"`
	Medias []Media `json:"medias"`

	//PortsPool is an array of ports that were used by backends, but now are free (because of a deactivation)
	PortsPool []int
	//LastPortUsed is a counter and allow to generate a new free port number
	NextFreePortNumber int
}

MediasConfig encapsulates all configuration data

swagger:model

func NewConfiguration

func NewConfiguration() *Configuration

type Manager

type Manager struct {
	Config *Configuration
	// contains filtered or unexported fields
}

func NewManager

func NewManager(pluginManager *plugins.Manager, clientsService *clients.Service, configPath, configFilename string) *Manager

func (*Manager) Activate

func (m *Manager) Activate(media *Media) error

func (*Manager) Commit

func (m *Manager) Commit() error

Commit SaveIntoDB all medias in DB. Here DB is a JSON file

func (*Manager) CreateEmpty

func (m *Manager) CreateEmpty(owner string) *Media

CreateMedia Create a new Media, save it into memory and commit

func (*Manager) CreateSaveFileIfNotExist

func (m *Manager) CreateSaveFileIfNotExist(filePath string, fileName string)

CreateSaveFileIfNotExist check if the save file for medias exists and create it if not.

func (*Manager) Deactivate

func (m *Manager) Deactivate(media *Media) error

func (*Manager) Delete

func (m *Manager) Delete(media *Media) error

func (*Manager) FreePortNumberForPlugin

func (m *Manager) FreePortNumberForPlugin(portNumber int)

func (*Manager) Get

func (m *Manager) Get(idMedia int) (*Media, error)

GetMedia Return the media with this id

func (*Manager) GetAll

func (m *Manager) GetAll() []Media

func (*Manager) GetConfig

func (m *Manager) GetConfig() interface{}

func (*Manager) GetConfiguration

func (m *Manager) GetConfiguration() *Configuration

func (*Manager) GetNextID

func (m *Manager) GetNextID() int

func (*Manager) GetPluginDirectory

func (m *Manager) GetPluginDirectory(media *Media, eltName string, instanceId string) string

func (*Manager) GetPortNumberForPlugin

func (m *Manager) GetPortNumberForPlugin() int

func (*Manager) GetSaveFilePath

func (m *Manager) GetSaveFilePath() (string, string, string)

func (*Manager) LoadFromDB

func (m *Manager) LoadFromDB()

LoadMedias loads medias configuration from DB and stor it in memory

func (*Manager) RemoveFromDB

func (m *Manager) RemoveFromDB(media *Media)

RemoveMedia RemoveFromDB media from memory

func (*Manager) SaveIntoDB

func (m *Manager) SaveIntoDB(media *Media)

SaveIntoDB saves media information in memory.

type Media

type Media struct {
	// the id for this media
	//
	// required: true
	// unique: true
	// min: 1
	ID          int                    `json:"id"`
	Name        string                 `json:"name"`
	IsActive    bool                   `json:"isactive"`
	Description string                 `json:"description"`
	Rows        int                    `json:"rows"`
	Cols        int                    `json:"cols"`
	Stylesvar   map[string]interface{} `json:"stylesvar"`
	Plugins     []MediaPlugin          `json:"plugins"`
	Owner       string                 `json:"owner"`
	ScreenRatio float64                `json:"screenRatio"`
	DisplayGrid bool                   `json:"displayGrid"`
}

Media represents a media configuration

swagger:model

func NewMedia

func NewMedia() *Media

type MediaPlugin

type MediaPlugin struct {
	InstanceId string               `json:"instanceId"`
	EltName    string               `json:"eltName"`
	FrontEnd   *MediaPluginFrontEnd `json:"frontend"`
	BackEnd    *MediaPluginBackEnd  `json:"backend"`
}

MediaPlugin represents a plugin configuration for the media

Properties and configuration for a plugin used in the media

swagger:model

type MediaPluginBackEnd

type MediaPluginBackEnd struct {
	Port              int                    `json:"port"`
	Props             map[string]interface{} `json:"props"`
	DockerImageName   string
	DockerContainerId string
}

type MediaPluginFrontEnd

type MediaPluginFrontEnd struct {
	//Files []string               `json:"files"`
	X     int                    `json:"x"`
	Y     int                    `json:"y"`
	Rows  int                    `json:"rows"`
	Cols  int                    `json:"cols"`
	Props map[string]interface{} `json:"props"`
}

type Service

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

func NewService

func NewService(pluginManager *plugins.Manager, clientsService *clients.Service) *Service

func (*Service) ActivateHandler

func (m *Service) ActivateHandler(w http.ResponseWriter, r *http.Request)

swagger:route GET /medias/{idMedia:[0-9]*}/activate ActivateHandler

If the media was deactivated (IsActive==false), backends for its plugins are started

Schemes: http, https

func (*Service) CreateHandler

func (m *Service) CreateHandler(w http.ResponseWriter, r *http.Request)

swagger:route GET /medias CreateHandler

Gets information of all medias

Produces:
- application/json

Schemes: http, https

func (*Service) DeactivateHandler

func (m *Service) DeactivateHandler(w http.ResponseWriter, r *http.Request)

swagger:route GET /medias/{idMedia:[0-9]*}/deactivate DeactivateHandler

If the media was activated (IsActive==true), backends for its plugins are stopped

func (*Service) DeleteAllHandler

func (m *Service) DeleteAllHandler(w http.ResponseWriter, r *http.Request)

swagger:route DELETE /medias DeleteAllHandler

Delete all medias

func (*Service) DeleteHandler

func (m *Service) DeleteHandler(w http.ResponseWriter, r *http.Request)

swagger:route DELETE /medias/{idMedia:[0-9]*} DeleteHandler

Delete this media

func (*Service) GetAllHandler

func (m *Service) GetAllHandler(w http.ResponseWriter, r *http.Request)

swagger:route GET /medias GetAllHandler

Gets information of all medias

Produces:
- application/json

Schemes: http, https

func (*Service) GetConfigHandler

func (m *Service) GetConfigHandler(w http.ResponseWriter, r *http.Request)

swagger:route GET /medias/config GetConfigHandler

Gets information of all medias

Produces:
- application/json

Schemes: http, https

func (*Service) GetHandler

func (m *Service) GetHandler(w http.ResponseWriter, r *http.Request)

swagger:route GET /medias/{idMedia} GetHandler

Gets information of a media

Produces:
- application/json

Schemes: http, https

swagger:parameters idMedia

func (*Service) GetManager

func (m *Service) GetManager() *Manager

func (*Service) GetPluginFilesHandler

func (m *Service) GetPluginFilesHandler(w http.ResponseWriter, r *http.Request)

swagger:route GET /medias{idMedia:[0-9]*}/plugins/{eltName}/{instanceId}/*

Serves static frontend files of the given plugin instance for the given media.

func (*Service) RestartHandler

func (m *Service) RestartHandler(w http.ResponseWriter, r *http.Request)

swagger:route GET /medias/{idMedia:[0-9]*}/restart RestartHandler

restart backends for the plugins of this media

func (*Service) SaveHandler

func (m *Service) SaveHandler(w http.ResponseWriter, r *http.Request)

swagger:route POST /medias SaveHandler

SaveIntoDB a media. If it's an update of an existing media, it will be first deactivated (all plugins stopped)

prior to be activated and saved.

By default, the media will be activated

Consumes:
- application/json

Schemes: http, https

Jump to

Keyboard shortcuts

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