executor

package
v1.3.1-dev.18.0...-398431f Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

README

EdgeX Foundry System Management Executor

license

This README.md is geared toward a developer interested in creating their own executor. It includes related information that ties in with the System Management Agent (aka SMA). The main points are:

  • How the SMA passes service name, and action on the command line.
  • Current proxy-like behavior for stop/start/restart operations -- the SMA passes parameters received to executor as-is.
  • The Metrics Result Contract (and its support for embedding executor-specific results).

Passing Parameters to SMA on Command Line

Usage

./sys-mgmt-executor [service-name] [operation]

Where:

  • "service-name" is the name of the service to apply the operation to.
  • "operation" can be one of [start, stop, restart]

Note: neither operation, nor service-name are verified by the SMA before passing to the executor, the executor is responsible for ensuring invalid service names and operations are handled gracefully.

Examples of Usage (and Sample Responses)
  • ./sys-mgmt-executor edgex-support-notifications stop
bash-5.0# ./sys-mgmt-executor edgex-support-notifications stop
""
  • ./sys-mgmt-executor edgex-support-notifications start
bash-5.0# ./sys-mgmt-executor edgex-core-data start
""
  • ./sys-mgmt-executor edgex-support-notifications restart
bash-5.0# ./sys-mgmt-executor edgex-support-notifications restart
""

Current Proxy-like Behavior for Stop/Start/Restart Operations

The three POST operations delegated to the Executor

  • These operations involves a POST operation each, where the body is provided as a JSON payload.
  • Here is an example payload for the "start" operation:
{
    [
        "apiVersion": "v2",
        "serviceName": "edge-core-command",
        "action": "start"
    ],
    [
        "apiVersion": "v2",
        "serviceName": "edge-core-metadata",
        "action": "start"
    ],
    [
        "apiVersion": "v2",
        "serviceName": "edge-core-data",
        "action": "start"
    ]
}
  • And the Accompanying response:
[
    {
        "apiVersion": "v2",
        "statusCode": 200,
        "serviceName": "edgex-core-command"
    },
    {
        "apiVersion": "v2",
        "statusCode": 200,
        "serviceName": "edgex-core-metadata"
    },
    {
        "apiVersion": "v2",
        "statusCode": 200,
        "serviceName": "edgex-core-data"
    }
]
  • And here is an example payload for the "restart" operation:
{
    [
        "apiVersion": "v2",
        "serviceName": "edgex-support-notifications",
        "action": "restart"
    ]
}
  • And the accompanying response:
[
    {
        "apiVersion": "v2",
        "statusCode": 200,
        "serviceName": "edgex-support-notifications"
    }
]
Note
  • The example payload for the "stop" operation, while not shown here, is similar to the ones shown above.

Metrics Result Contract

  • The metrics result allows user to provide desired metrics field in map[string]interface{} format, here is the example response:
{
    "cpuUsedPercent": 5.08,
    "memoryUsed": 5488247,
    "raw": {
        "block_io": "8.19kB / 0B",
        "cpu_perc": "5.08%",
        "mem_perc": "0.26%",
        "mem_usage": "5.234MiB / 1.952GiB",
        "net_io": "277kB / 194kB",
        "pids": "14"
    }
}
Note
  • The expected format of the result is based upon the current Docker executor implementation.

License

Apache-2.0

Documentation

Index

Constants

View Source
const (
	Start   = "start"
	Stop    = "stop"
	Restart = "restart"
	Metrics = "metrics"
)

Variables

This section is empty.

Functions

func Execute

func Execute(args []string, executor CommandExecutor) (res interface{}, err error)

Execute is called from main (which supplies an executor) to process a request.

Types

type CommandExecutor

type CommandExecutor func(arg ...string) ([]byte, error)

CommandExecutor defines the function signature implemented by an underlying executor. The executor's responsibility is to take a series of arguments (i.e. service name, operation, etc.) "execute" the requested operation, and return a result. This abstraction was introduced to support unit testing.

Jump to

Keyboard shortcuts

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