1 | <?php |
||
19 | class CpeSqsWriter |
||
20 | { |
||
21 | private $debug; |
||
22 | private $sqs; |
||
23 | |||
24 | // Exceptions |
||
25 | const INVALID_JSON = "INVALID_JSON"; |
||
26 | |||
27 | // Statuses |
||
28 | const WORKFLOW_SCHEDULED = "WORKFLOW_SCHEDULED"; |
||
29 | const JOB_STARTED = "JOB_STARTED"; |
||
30 | const JOB_COMPLETED = "JOB_COMPLETED"; |
||
31 | const JOB_FAILED = "JOB_FAILED"; |
||
32 | const ACTIVITY_STARTED = "ACTIVITY_STARTED"; |
||
33 | const ACTIVITY_FAILED = "ACTIVITY_FAILED"; |
||
34 | const ACTIVITY_TIMEOUT = "ACTIVITY_TIMEOUT"; |
||
35 | const ACTIVITY_COMPLETED = "ACTIVITY_COMPLETED"; |
||
36 | const ACTIVITY_PROGRESS = "ACTIVITY_PROGRESS"; |
||
37 | const ACTIVITY_PREPARING = "ACTIVITY_PREPARING"; |
||
38 | const ACTIVITY_FINISHING = "ACTIVITY_FINISHING"; |
||
39 | |||
40 | public function __construct($debug) |
||
41 | { |
||
42 | $this->debug = $debug; |
||
43 | |||
44 | // Create AWS SDK instance. |
||
45 | // We expect an AWS role or the proper AWS env variable sets for KEY/SECRET |
||
46 | $aws = Aws::factory(array( |
||
47 | 'region' => getenv("AWS_DEFAULT_REGION") |
||
48 | )); |
||
49 | $this->sqs = $aws->get('Sqs'); |
||
50 | } |
||
51 | |||
52 | |||
53 | /** |
||
54 | * SEND messages to OUTPUT SQS queue |
||
55 | * |
||
56 | * Send messages to back to the clients. |
||
57 | * Clients listening to the SQS queue will receive them |
||
58 | * Send updates and notifications: |
||
59 | * Activity Started, Failed, Succeeded, etc |
||
60 | */ |
||
61 | |||
62 | public function workflow_scheduled($workflowType, $runId, $workflowId, $message) |
||
80 | |||
81 | public function activity_started($task) |
||
90 | |||
91 | public function activity_completed($task, $result = null) |
||
101 | |||
102 | public function activity_failed($task, $reason, $details) |
||
114 | |||
115 | public function activity_timeout($task) |
||
123 | |||
124 | public function activity_canceled($task) |
||
128 | |||
129 | public function activity_progress($task, $progress) |
||
138 | |||
139 | public function activity_preparing($task) |
||
146 | |||
147 | public function activity_finishing($task) |
||
154 | |||
155 | |||
156 | /** |
||
157 | * UTILS |
||
158 | */ |
||
159 | |||
160 | // Craft a new message array |
||
161 | private function craft_new_msg($type, $data) |
||
171 | |||
172 | // Send a message to SQS output queue |
||
173 | private function send_activity_msg( |
||
214 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.