nyaruka / goflow

Flow engine for RapidPro/TextIt.
Other
45 stars 20 forks source link

Asset item sets vs individual items #173

Closed rowanseymour closed 6 years ago

rowanseymour commented 6 years ago

There are places in goflow where we need the complete set of a thing and places where we need a specific thing. For example when we re-eval dynamic groups we need all groups, but an add_group action just needs specific groups.

Currently the way the asset cache is implemented, requesting a specific group will actually request all groups from RP, and then look for the requested group in that set. This avoids having the group exist in two different places in the cache (as an individual item and as part of the set). This is the same for fields, channels, labels. The only asset type which differs is flows - they are always fetched individually.

But this means you can't actually add an individual group/channel/label/field to the asset cache. If that' useful we need to find a way to support it. If it's not then we should clean up the asset cache code so that doesn't appear to be possible, i.e. the supported asset types become: flow, group_set, field_set etc.

rowanseymour commented 6 years ago

One place it might be useful to be able to bundle an individual asset is when invoking the flowserver from the rapidpro simulator - you could create a channel asset that doesn't even exist in the database and just bundle it with your requests.

rowanseymour commented 6 years ago

Having solved the simulator channel problem by just adding it to the end of requests for all channels, my inclination is now simplifying assets so that things are either sets or individual items:

"asset_server": {
  "type_urls": {
    "flow": "http://testserver/flow/1/assets/flow/{uuid}/",
    "channel_set": "http://testserver/flow/1/assets/channel/",
    "group_set": "http://testserver/flow/1/assets/group/",
  } 
}