MCPcopy Create free account
hub / github.com/StackStorm/st2 / poll

Method poll

contrib/examples/sensors/sample_polling_sensor.py:37–55  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

35 pass
36
37 def poll(self):
38 # This is where the crux of the sensor work goes.
39 # This is called every self._poll_interval.
40 # For example, let's assume you want to query ec2 and get
41 # health information about your instances:
42 # some_data = aws_client.get('')
43 # payload = self._to_payload(some_data)
44 # # _to_triggers is something you'd write to convert the data format you have
45 # # into a standard python dictionary. This should follow the payload schema
46 # # registered for the trigger.
47 # self.sensor_service.dispatch(trigger, payload)
48 # # You can refer to the trigger as dict
49 # # { "name": ${trigger_name}, "pack": ${trigger_pack} }
50 # # or just simply by reference as string.
51 # # i.e. dispatch(${trigger_pack}.${trigger_name}, payload)
52 # # E.g.: dispatch('examples.foo_sensor', {'k1': 'stuff', 'k2': 'foo'})
53 # # trace_tag is a tag you would like to associate with the dispatched TriggerInstance
54 # # Typically the trace_tag is unique and a reference to an external event.
55 pass
56
57 def cleanup(self):
58 # This is called when the st2 system goes down. You can perform cleanup operations like

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected