Dynamic type Loading - dm03514/func-y-task-engine GitHub Wiki

Each event attribute type is loaded dynamically.

The type refers to a python package and class inside the package.

Take the following event for example:

  - name: google_request
    event_fulfillment_strategy:
       type: poll.PollerFulfillment
       frequency_ms: 200
    transition_conditions:
       - type: assertions.Equal
         value_property: status_code
         to_equal: 200
    initiator:
      method: get
      type: http.HTTPInitiator
      url: "http://google.com"

Each type is of the following format:

{{ python_package }}.{{ class_in_package }}

Each of the event sections: event_fulfillment_strategy, transition_conditions, and initiator map to top level packages in the repo:

⟫ tree -L 1 funcytestengine/
funcytestengine/
├── event_fulfillment
├── initiators
│   ├── http.py
│   ├── __init__.py
│   ├── noop.py
│   ├── nsq.py
│   ├── postgres.py
└── transition_conditions

After YAML is parsed and as the state machine is being constructed, the parser will look in the initiators.http file and then access the HTTPInitiator attribute.