Documentation
¶
Overview ¶
Package dep_manager tracks the dependency manager in the local context.
Index ¶
- Constants
- type Dep
- type DepManager
- func (manager *DepManager) Close(c *clientConfig.Client) error
- func (manager *DepManager) Install(dep *Dep, parent *log.Logger) error
- func (manager *DepManager) Installed(dep *Dep) bool
- func (manager *DepManager) Lint(dep *Dep)
- func (manager *DepManager) OnStop(id string) chan error
- func (manager *DepManager) Run(dep *Dep, id string, optionalParent ...*clientConfig.Client) error
- func (manager *DepManager) Running(c *clientConfig.Client) (bool, error)
- func (manager *DepManager) SetPaths(srcPath string, binPath string) error
- func (manager *DepManager) Uninstall(dep *Dep) error
- type Interface
Constants ¶
const DefaultTimeout = time.Second
DefaultTimeout is the default time to wait before considering the message is not delivered. DepManager.Running method uses this value before considering the socket as not running.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dep ¶
type DepManager ¶
type DepManager struct { Src string `json:"SERVICE_DEPS_SRC"` // Default Src path Bin string `json:"SERVICE_DEPS_BIN"` // contains filtered or unexported fields }
A DepManager Manager builds, runs or stops the dependency services
func New ¶
func New() *DepManager
New source manager in the Dev context.
It will prepare the directories for source codes and binary. If preparation fails, it will throw an error.
func (*DepManager) Close ¶
func (manager *DepManager) Close(c *clientConfig.Client) error
Close the dependency
func (*DepManager) Install ¶
func (manager *DepManager) Install(dep *Dep, parent *log.Logger) error
Install method builds the binary from the source code. The binary exists, then its over-written. The Dep binary must be manageable. If the Dep source code is manageable, then missing source code is downloaded as well.
Returns an error in two cases:
- If the dependency binary is not manageable by the DepManager.
- If no source code was given, and source code is not manageable by the DepManager.
func (*DepManager) Installed ¶
func (manager *DepManager) Installed(dep *Dep) bool
Installed checks is the binary exist.
Whether the depManager is manageable or not doesn't matter.
func (*DepManager) Lint ¶
func (manager *DepManager) Lint(dep *Dep)
Lint sets the fields of Dep as for caching. The two primary flags are whether the Dep is managed by DepManager or not.
The Dep source code is manageable if it doesn't have Dep.LocalUrl(). The Dep binary is manageable if it binary path is not within the DepManager.Bin directory
func (*DepManager) OnStop ¶
func (manager *DepManager) OnStop(id string) chan error
OnStop returns a signal through the channel when the dependency spawned by the DepManager stops. If the dep is not existing, then it will simply return error.
func (*DepManager) Run ¶
func (manager *DepManager) Run(dep *Dep, id string, optionalParent ...*clientConfig.Client) error
Run runs the binary. If it fails to run, then it will return an error.
Note that, services can crash during the initialization. In that case, you should use DepManager.OnStop method.
If a parent is given, it's passed as ParentFlag. Todo, move all Flags from service-lib to config-lig. Todo, use the ParentFlag from the config lig
func (*DepManager) Running ¶
func (manager *DepManager) Running(c *clientConfig.Client) (bool, error)
Running checks whether the given client running or not. If the service is running on another process or on another node, then that service should expose the port.
func (*DepManager) SetPaths ¶
func (manager *DepManager) SetPaths(srcPath string, binPath string) error
func (*DepManager) Uninstall ¶
func (manager *DepManager) Uninstall(dep *Dep) error
Uninstall deletes the dependency source code, and its binary. Trying to uninstall already running application will fail.
Uninstall will omit if no binary or source code exists. Uninstall won't take effect if depManager is not manageable.
type Interface ¶
type Interface interface { // Installed checks is the service binary exists Installed(dep *Dep) bool // Install the dependency from the source code. It compiles it. Install(dep *Dep, logger *log.Logger) error // Run the dependency with the given id and parent. Run(dep *Dep, id string, optionalParent ...*clientConfig.Client) error // Uninstall the dependency. Uninstall(dep *Dep) error // Lint sets the flags in the Dep if this depManager is managed by the DepManager Lint(*Dep) // Running checks is the service running or not Running(*clientConfig.Client) (bool, error) // Close the given dependency service Close(c *clientConfig.Client) error }
The Interface of the dependency manager.
It doesn't have the `Stop` command. Because, stopping must be done by the remote call from other services.