Documentation
¶
Index ¶
Constants ¶
View Source
const ( // Default timeout in milliseconds DefaultTimeout = 1000 // Buffer size in bytes for incoming connections ConnBufferSize = 2048 )
Variables ¶
View Source
var ( // Read unlimited lines until the default timeout DefaultHeader = "-1:" // Command not allowed (will not be sent to Wrapper) ForbiddenHeader = "-:" // Do not wait for any response EmptyHeader = ":" ErrMissingHeader = fmt.Errorf("missing or invalid socketcmd header") ErrCommandForbidden = fmt.Errorf("the provided command is not allowed") )
Functions ¶
func DefaultParseFunc ¶
func ParseHeader ¶
ParseHeader extracts the line count and timeout from the given header.
Types ¶
type Client ¶
type Client interface {
/* Dialer sets the dialer configuration used by the Client.
*/
Dialer(net.Dialer)
/* Send the given arguments to the socket Wrapper. The Client's parser function is used
* to generate the socketcmd header appropriate for the given arguments.
*/
Send(args ...string) ([]string, error)
/* SendContext sends the given arguments to the socket Wrapper, using the given context
* to manage the connection. The Client's parser function is used to generate the
* socketcmd header appropriate for the given arguments.
*/
SendContext(ctx context.Context, args ...string) ([]string, error)
}
A Client connects to a Wrapper's socket.
type Handler ¶
type Handler interface {
// Addr returns the address of the underlying net Listener.
Addr() net.Addr
// Close the socket listener.
Close() error
// Start the goroutines for managing process I/O redirection.
Start()
}
A Handler manages network socket and I/O redirection.
type Wrapper ¶
type Wrapper interface {
// Addr returns the address of the underlying net Listener.
Addr() net.Addr
// Run the wrapped process.
Run() error
// Start the wrapped process.
Start() error
// Wait for the wrapped process to exit.
Wait() error
// ExposeAPI for high-level network operations.
ExposeAPI(ParseFunc) WrapperAPI
}
A Wrapper provides I/O redirection for a process. Input to the Wrapper's network socket * will be forwarded to the process, with the resulting lines of stdout returned to the * socket client.
type WrapperAPI ¶
type WrapperAPI interface {
Wrapper
/* Listen on the given address and serve the command endpoint at the given path.
*/
Listen(addr, path string) error
/* Default Handler function for the WrapperAPI. This method may be used to integrate
* the WrapperAPI into an existing API or extend it with other endpoints. This endpoint
* expects to receive a command sequence as an array of strings in JSON format. If the
* first element is a valid socketcmd Header then it will be used to parse the response.
* Otherwise, the configured ParseFunc will be used to generate a header based on the
* given command sequence. The response will by sent back as a JSON array of strings.
*/
CommandEndpoint(http.ResponseWriter, *http.Request)
}
A WrapperAPI extends an enclosed Wrapper with high-level remote API operations.
Click to show internal directories.
Click to hide internal directories.