Class: WorkContext
task/work.WorkContext
Groups most common operations that the requestors might need to implement their workflows
Table of contents
Constructors
Properties
Methods
- before
- run
- spawn
- runAndStream
- transfer
- uploadFile
- uploadJson
- uploadData
- downloadFile
- downloadData
- downloadJson
- beginBatch
- getWebsocketUri
- getIp
- createTcpProxy
- getState
Constructors
constructor
• new WorkContext(activity
, options
): WorkContext
Parameters
Name | Type |
---|---|
activity | Activity |
options | WorkOptions |
Returns
Defined in
Properties
provider
• Readonly
provider: ProviderInfo
Defined in
activity
• Readonly
activity: Activity
Defined in
Methods
before
▸ before(): Promise
<void
| Result
<any
>[]>
Returns
Promise
<void
| Result
<any
>[]>
Defined in
run
▸ run(commandLine
, options?
): Promise
<Result
<any
>>
Execute a command on provider using a shell (/bin/sh).
Parameters
Name | Type | Description |
---|---|---|
commandLine | string | Shell command to execute. |
options? | CommandOptions | Additional run options. |
Returns
Promise
<Result
<any
>>
Defined in
▸ run(executable
, args
, options?
): Promise
<Result
<any
>>
Execute an executable on provider.
Parameters
Name | Type | Description |
---|---|---|
executable | string | Executable to run. |
args | string [] | Executable arguments. |
options? | CommandOptions | Additional run options. |
Returns
Promise
<Result
<any
>>
Defined in
spawn
▸ spawn(commandLine
, options?
): Promise
<RemoteProcess
>
Parameters
Name | Type |
---|---|
commandLine | string |
options? | Omit <CommandOptions , "capture" > |
Returns
Promise
<RemoteProcess
>
Deprecated
Use WorkContext.runAndStream instead
Defined in
▸ spawn(executable
, args
, options?
): Promise
<RemoteProcess
>
Parameters
Name | Type |
---|---|
executable | string |
args | string [] |
options? | CommandOptions |
Returns
Promise
<RemoteProcess
>
Deprecated
Use WorkContext.runAndStream instead
Defined in
runAndStream
▸ runAndStream(commandLine
, options?
): Promise
<RemoteProcess
>
Run an executable on provider and return RemoteProcess that will allow streaming that contain stdout and stderr as Readable
Parameters
Name | Type | Description |
---|---|---|
commandLine | string | Shell command to execute. |
options? | Omit <CommandOptions , "capture" > | Additional run options. |
Returns
Promise
<RemoteProcess
>
Defined in
▸ runAndStream(executable
, args
, options?
): Promise
<RemoteProcess
>
Parameters
Name | Type | Description |
---|---|---|
executable | string | Executable to run. |
args | string [] | Executable arguments. |
options? | CommandOptions | Additional run options. |
Returns
Promise
<RemoteProcess
>
Defined in
transfer
▸ transfer(from
, to
, options?
): Promise
<Result
<any
>>
Generic transfer command, requires the user to provide a publicly readable transfer source
Parameters
Name | Type | Description |
---|---|---|
from | string | publicly available resource for reading. Supported protocols: file, http, ftp or gftp |
to | string | file path |
options? | CommandOptions | Additional run options. |
Returns
Promise
<Result
<any
>>
Defined in
uploadFile
▸ uploadFile(src
, dst
, options?
): Promise
<Result
<any
>>
Parameters
Name | Type |
---|---|
src | string |
dst | string |
options? | CommandOptions |
Returns
Promise
<Result
<any
>>
Defined in
uploadJson
▸ uploadJson(json
, dst
, options?
): Promise
<Result
<any
>>
Parameters
Name | Type |
---|---|
json | any |
dst | string |
options? | CommandOptions |
Returns
Promise
<Result
<any
>>
Defined in
uploadData
▸ uploadData(data
, dst
, options?
): Promise
<Result
<any
>>
Parameters
Name | Type |
---|---|
data | Uint8Array |
dst | string |
options? | CommandOptions |
Returns
Promise
<Result
<any
>>
Defined in
downloadFile
▸ downloadFile(src
, dst
, options?
): Promise
<Result
<any
>>
Parameters
Name | Type |
---|---|
src | string |
dst | string |
options? | CommandOptions |
Returns
Promise
<Result
<any
>>
Defined in
downloadData
▸ downloadData(src
, options?
): Promise
<Result
<Uint8Array
>>
Parameters
Name | Type |
---|---|
src | string |
options? | CommandOptions |
Returns
Promise
<Result
<Uint8Array
>>
Defined in
downloadJson
▸ downloadJson(src
, options?
): Promise
<Result
<any
>>
Parameters
Name | Type |
---|---|
src | string |
options? | CommandOptions |
Returns
Promise
<Result
<any
>>
Defined in
beginBatch
▸ beginBatch(): Batch
Returns
Defined in
getWebsocketUri
▸ getWebsocketUri(port
): string
Provides a WebSocket URI that allows communicating with a remote process listening on the target port
Parameters
Name | Type | Description |
---|---|---|
port | number | The port number used by the service running within an activity on the provider |
Returns
string
Defined in
getIp
▸ getIp(): string
Returns
string
Defined in
createTcpProxy
▸ createTcpProxy(portOnProvider
): TcpProxy
Creates a new TCP proxy that will allow tunnelling the TPC traffic from the provider via the requestor
Parameters
Name | Type | Description |
---|---|---|
portOnProvider | number | The port that the service running on the provider is listening to |
Returns
Defined in
getState
▸ getState(): Promise
<ActivityStateEnum
>
Returns
Promise
<ActivityStateEnum
>