agent

package
v1.0.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2017 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIService added in v1.0.0

type APIService struct {
	*Context
	// contains filtered or unexported fields
}

APIService .

func NewAPIV1 added in v1.0.0

func NewAPIV1(ctx *Context) *APIService

NewAPIV1 creates a new instance of API service

func (*APIService) AddXdsServer added in v1.0.0

func (s *APIService) AddXdsServer(cfg xdsconfig.XDSServerConf) (*XdsServer, error)

AddXdsServer Add a new XDS Server to the list of a server

func (*APIService) DelXdsServer added in v1.0.0

func (s *APIService) DelXdsServer(id string) error

DelXdsServer Delete an XDS Server from the list of a server

func (*APIService) Stop added in v1.0.0

func (s *APIService) Stop()

Stop Used to stop/close created services

type ClientSession added in v1.0.0

type ClientSession struct {
	ID       string
	WSID     string // only one WebSocket per client/session
	MaxAge   int64
	IOSocket *socketio.Socket
	// contains filtered or unexported fields
}

ClientSession contains the info of a user/client session

type Context

type Context struct {
	ProgName      string
	Config        *xdsconfig.Config
	Log           *logrus.Logger
	LogLevelSilly bool
	LogSillyf     func(format string, args ...interface{})
	SThg          *st.SyncThing
	SThgCmd       *exec.Cmd
	SThgInotCmd   *exec.Cmd

	Exit chan os.Signal
	// contains filtered or unexported fields
}

Context holds the Agent context structure

func NewAgent

func NewAgent(cliCtx *cli.Context) *Context

NewAgent Create a new instance of Agent

func (*Context) Run added in v1.0.0

func (ctx *Context) Run() (int, error)

Run Main function called to run agent

type EventCB added in v1.0.0

type EventCB func(privData interface{}, evtData interface{}) error

EventCB Event emitter callback

type EventDef added in v1.0.0

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

EventDef Definition on one event

type Events added in v1.0.0

type Events struct {
	*Context
	// contains filtered or unexported fields
}

Events Hold registered events per context

func NewEvents added in v1.0.0

func NewEvents(ctx *Context) *Events

NewEvents creates an instance of Events

func (*Events) Emit added in v1.0.0

func (e *Events) Emit(evName string, data interface{}, fromSid string) error

Emit Used to manually emit an event

func (*Events) GetList added in v1.0.0

func (e *Events) GetList() []string

GetList returns the list of all supported events

func (*Events) Register added in v1.0.0

func (e *Events) Register(evName, sessionID string) error

Register Used by a client/session to register to a specific (or all) event(s)

func (*Events) UnRegister added in v1.0.0

func (e *Events) UnRegister(evName, sessionID string) error

UnRegister Used by a client/session to unregister event(s)

type IPROJECT added in v1.0.0

type IPROJECT interface {
	Add(cfg xaapiv1.ProjectConfig) (*xaapiv1.ProjectConfig, error)    // Add a new project
	Setup(prj xaapiv1.ProjectConfig) (*xaapiv1.ProjectConfig, error)  // Local setup of the project
	Delete() error                                                    // Delete a project
	GetProject() *xaapiv1.ProjectConfig                               // Get project public configuration
	Update(prj xaapiv1.ProjectConfig) (*xaapiv1.ProjectConfig, error) // Update project configuration
	GetServer() *XdsServer                                            // Get XdsServer that holds this project
	Sync() error                                                      // Force project files synchronization
	IsInSync() (bool, error)                                          // Check if project files are in-sync
}

IPROJECT Project interface

type PathMap added in v1.0.0

type PathMap struct {
	*Context
	// contains filtered or unexported fields
}

PathMap .

func NewProjectPathMap added in v1.0.0

func NewProjectPathMap(ctx *Context, svr *XdsServer) *PathMap

NewProjectPathMap Create a new instance of PathMap

func (*PathMap) Add added in v1.0.0

Add a new project

func (*PathMap) Delete added in v1.0.0

func (p *PathMap) Delete() error

Delete a project

func (*PathMap) GetProject added in v1.0.0

func (p *PathMap) GetProject() *xaapiv1.ProjectConfig

GetProject Get public part of project config

func (*PathMap) GetServer added in v1.0.0

func (p *PathMap) GetServer() *XdsServer

GetServer Get the XdsServer that holds this project

func (*PathMap) IsInSync added in v1.0.0

func (p *PathMap) IsInSync() (bool, error)

IsInSync Check if project files are in-sync

func (*PathMap) Setup added in v1.0.0

Setup Setup local project config

func (*PathMap) Sync added in v1.0.0

func (p *PathMap) Sync() error

Sync Force project files synchronization

func (*PathMap) Update added in v1.0.0

Update Update some field of a project

type Projects added in v1.0.0

type Projects struct {
	*Context
	SThg *st.SyncThing
	// contains filtered or unexported fields
}

Projects Represent a an XDS Projects

func NewProjects added in v1.0.0

func NewProjects(ctx *Context, st *st.SyncThing) *Projects

NewProjects Create a new instance of Project Model

func (*Projects) Add added in v1.0.0

func (p *Projects) Add(newP xaapiv1.ProjectConfig, fromSid, requestURL string) (*xaapiv1.ProjectConfig, error)

Add adds a new folder

func (*Projects) Delete added in v1.0.0

func (p *Projects) Delete(id, fromSid string) (xaapiv1.ProjectConfig, error)

Delete deletes a specific folder

func (*Projects) ForceSync added in v1.0.0

func (p *Projects) ForceSync(id string) error

ForceSync Force the synchronization of a folder

func (*Projects) Get added in v1.0.0

func (p *Projects) Get(id string) *IPROJECT

Get returns the folder config or nil if not existing

func (*Projects) GetProjectArr added in v1.0.0

func (p *Projects) GetProjectArr() []xaapiv1.ProjectConfig

GetProjectArr returns the config of all folders as an array

func (*Projects) GetProjectArrUnsafe added in v1.0.0

func (p *Projects) GetProjectArrUnsafe() []xaapiv1.ProjectConfig

GetProjectArrUnsafe Same as GetProjectArr without mutex protection

func (*Projects) Init added in v1.0.0

func (p *Projects) Init(server *XdsServer) error

Init Load Projects configuration

func (*Projects) IsProjectInSync added in v1.0.0

func (p *Projects) IsProjectInSync(id string) (bool, error)

IsProjectInSync Returns true when folder is in sync

func (*Projects) ResolveID added in v1.0.0

func (p *Projects) ResolveID(id string) (string, error)

ResolveID Complete a Project ID (helper for user that can use partial ID value)

func (*Projects) Update added in v1.0.0

func (p *Projects) Update(id string, prj xaapiv1.ProjectConfig, fromSid string) (*xaapiv1.ProjectConfig, error)

Update Update some field of a project

type STProject added in v1.0.0

type STProject struct {
	*Context
	// contains filtered or unexported fields
}

STProject .

func NewProjectST added in v1.0.0

func NewProjectST(ctx *Context, svr *XdsServer) *STProject

NewProjectST Create a new instance of STProject

func (*STProject) Add added in v1.0.0

Add a new project

func (*STProject) Delete added in v1.0.0

func (p *STProject) Delete() error

Delete a project

func (*STProject) GetProject added in v1.0.0

func (p *STProject) GetProject() *xaapiv1.ProjectConfig

GetProject Get public part of project config

func (*STProject) GetServer added in v1.0.0

func (p *STProject) GetServer() *XdsServer

GetServer Get the XdsServer that holds this project

func (*STProject) IsInSync added in v1.0.0

func (p *STProject) IsInSync() (bool, error)

IsInSync Check if project files are in-sync

func (*STProject) Setup added in v1.0.0

Setup Setup local project config

func (*STProject) Sync added in v1.0.0

func (p *STProject) Sync() error

Sync Force project files synchronization

func (*STProject) Update added in v1.0.0

Update Update some field of a project

type Sessions added in v1.0.0

type Sessions struct {
	*Context
	// contains filtered or unexported fields
}

Sessions holds client sessions

func NewClientSessions added in v1.0.0

func NewClientSessions(ctx *Context, cookieMaxAge string) *Sessions

NewClientSessions .

func (*Sessions) Get added in v1.0.0

func (s *Sessions) Get(c *gin.Context) *ClientSession

Get returns the client session for a specific ID

func (*Sessions) GetID added in v1.0.0

func (s *Sessions) GetID(c *gin.Context) string

GetID returns the session or an empty string

func (*Sessions) IOSocketGet added in v1.0.0

func (s *Sessions) IOSocketGet(sid string) *socketio.Socket

IOSocketGet Get socketio definition from sid

func (*Sessions) Middleware added in v1.0.0

func (s *Sessions) Middleware() gin.HandlerFunc

Middleware is used to managed session

func (*Sessions) Stop added in v1.0.0

func (s *Sessions) Stop()

Stop sessions management

func (*Sessions) UpdateIOSocket added in v1.0.0

func (s *Sessions) UpdateIOSocket(sid string, so *socketio.Socket) error

UpdateIOSocket updates the IO Socket definition for of a session

type WebServer added in v1.0.0

type WebServer struct {
	*Context
	// contains filtered or unexported fields
}

WebServer .

func NewWebServer added in v1.0.0

func NewWebServer(ctx *Context) *WebServer

NewWebServer creates an instance of WebServer

func (*WebServer) Serve added in v1.0.0

func (s *WebServer) Serve() error

Serve starts a new instance of the Web Server

func (*WebServer) Stop added in v1.0.0

func (s *WebServer) Stop()

Stop web server

type XdsServer added in v1.0.0

type XdsServer struct {
	*Context
	ID           string
	BaseURL      string
	APIURL       string
	PartialURL   string
	ConnRetry    int
	Connected    bool
	Disabled     bool
	ServerConfig *xsapiv1.APIConfig

	// Events management
	CBOnError      func(error)
	CBOnDisconnect func(error)
	// contains filtered or unexported fields
}

XdsServer .

func NewXdsServer added in v1.0.0

func NewXdsServer(ctx *Context, conf xdsconfig.XDSServerConf) *XdsServer

NewXdsServer creates an instance of XdsServer

func (*XdsServer) Close added in v1.0.0

func (xs *XdsServer) Close() error

Close Free and close XDS Server connection

func (*XdsServer) CommandAdd added in v1.0.0

func (xs *XdsServer) CommandAdd(cmdID string, data interface{}) error

CommandAdd Add a new command to the list of running commands

func (*XdsServer) CommandDelete added in v1.0.0

func (xs *XdsServer) CommandDelete(cmdID string) error

CommandDelete Delete a command from the command list

func (*XdsServer) CommandExec added in v1.0.0

func (xs *XdsServer) CommandExec(args *xsapiv1.ExecArgs, res *xsapiv1.ExecResult) error

CommandExec Send POST request to execute a command

func (*XdsServer) CommandGet added in v1.0.0

func (xs *XdsServer) CommandGet(cmdID string) interface{}

CommandGet Retrieve a command data

func (*XdsServer) CommandSignal added in v1.0.0

func (xs *XdsServer) CommandSignal(args *xsapiv1.ExecSignalArgs, res *xsapiv1.ExecSigResult) error

CommandSignal Send POST request to send a signal to a command

func (*XdsServer) Connect added in v1.0.0

func (xs *XdsServer) Connect() error

Connect Establish HTTP connection with XDS Server

func (*XdsServer) EventEmit added in v1.0.0

func (xs *XdsServer) EventEmit(message string, args ...interface{}) error

EventEmit Emit a event to XDS Server through WS

func (*XdsServer) EventOff added in v1.0.0

func (xs *XdsServer) EventOff(evName string, id uuid.UUID) error

EventOff Un-register a (or all) callbacks associated to an event

func (*XdsServer) EventOn added in v1.0.0

func (xs *XdsServer) EventOn(evName string, privData interface{}, f EventCB) (uuid.UUID, error)

EventOn Register a callback on events reception

func (*XdsServer) EventRegister added in v1.0.0

func (xs *XdsServer) EventRegister(evName string, filter string) error

EventRegister Post a request to register to an XdsServer event

func (*XdsServer) FolderAdd added in v1.0.0

func (xs *XdsServer) FolderAdd(fld *xsapiv1.FolderConfig, res interface{}) error

FolderAdd Send POST request to add a folder

func (*XdsServer) FolderDelete added in v1.0.0

func (xs *XdsServer) FolderDelete(id string) error

FolderDelete Send DELETE request to delete a folder

func (*XdsServer) FolderSync added in v1.0.0

func (xs *XdsServer) FolderSync(id string) error

FolderSync Send POST request to force synchronization of a folder

func (*XdsServer) FolderToProject added in v1.0.0

func (xs *XdsServer) FolderToProject(fPrj xsapiv1.FolderConfig) xaapiv1.ProjectConfig

FolderToProject Convert Folder structure to Project structure

func (*XdsServer) FolderUpdate added in v1.0.0

func (xs *XdsServer) FolderUpdate(fld *xsapiv1.FolderConfig, resFld *xsapiv1.FolderConfig) error

FolderUpdate Send PUT request to update a folder

func (*XdsServer) GetFolders added in v1.0.0

func (xs *XdsServer) GetFolders(folders *[]xsapiv1.FolderConfig) error

GetFolders Send GET request to get current folder configuration

func (*XdsServer) GetVersion added in v1.0.0

func (xs *XdsServer) GetVersion(res interface{}) error

GetVersion Send Get request to retrieve XDS Server version

func (*XdsServer) IsTempoID added in v1.0.0

func (xs *XdsServer) IsTempoID() bool

IsTempoID returns true when server as a temporary id

func (*XdsServer) PassthroughDelete added in v1.0.0

func (xs *XdsServer) PassthroughDelete(url string)

PassthroughDelete Used to declare a route that sends directly a Delete request to XDS Server

func (*XdsServer) PassthroughGet added in v1.0.0

func (xs *XdsServer) PassthroughGet(url string)

PassthroughGet Used to declare a route that sends directly a GET request to XDS Server

func (*XdsServer) PassthroughPost added in v1.0.0

func (xs *XdsServer) PassthroughPost(url string)

PassthroughPost Used to declare a route that sends directly a POST request to XDS Server

func (*XdsServer) ProjectToFolder added in v1.0.0

func (xs *XdsServer) ProjectToFolder(pPrj xaapiv1.ProjectConfig) *xsapiv1.FolderConfig

ProjectToFolder Convert Project structure to Folder structure

func (*XdsServer) SendCommand added in v1.0.0

func (xs *XdsServer) SendCommand(cmd string, body []byte, res interface{}) error

SendCommand Send a command to XDS Server

func (*XdsServer) SetAPIRouterGroup added in v1.0.0

func (xs *XdsServer) SetAPIRouterGroup(r *gin.RouterGroup)

SetAPIRouterGroup .

func (*XdsServer) SetLoggerOutput added in v1.0.0

func (xs *XdsServer) SetLoggerOutput(out io.Writer)

SetLoggerOutput Set logger ou

Jump to

Keyboard shortcuts

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