{"action":"created","issue":{"url":"https://api.github.com/repos/nyaruka/goflow/issues/75","repository_url":"https://api.github.com/repos/nyaruka/goflow","labels_url":"https://api.github.com/repos/nyaruka/goflow/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/nyaruka/goflow/issues/75/comments","events_url":"https://api.github.com/repos/nyaruka/goflow/issues/75/events","html_url":"https://github.com/nyaruka/goflow/issues/75","id":246253753,"number":75,"title":"Asset caching and lazy loading","user":{"login":"rowanseymour","id":675558,"avatar_url":"https://avatars0.githubusercontent.com/u/675558?v=4","gravatar_id":"","url":"https://api.github.com/users/rowanseymour","html_url":"https://github.com/rowanseymour","followers_url":"https://api.github.com/users/rowanseymour/followers","following_url":"https://api.github.com/users/rowanseymour/following{/other_user}","gists_url":"https://api.github.com/users/rowanseymour/gists{/gist_id}","starred_url":"https://api.github.com/users/rowanseymour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rowanseymour/subscriptions","organizations_url":"https://api.github.com/users/rowanseymour/orgs","repos_url":"https://api.github.com/users/rowanseymour/repos","events_url":"https://api.github.com/users/rowanseymour/events{/privacy}","received_events_url":"https://api.github.com/users/rowanseymour/received_events","type":"User","site_admin":false},"labels":[{"id":602341342,"url":"https://api.github.com/repos/nyaruka/goflow/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-07-28T06:26:27Z","updated_at":"2017-08-02T12:24:50Z","closed_at":null,"body":"We need a solution that:\r\n\r\n- Avoids the caller needing to sending flow (etc) definitions with every request\r\n- Supports location data being an asset type and thus solves https://github.com/nyaruka/goflow/issues/71\r\n- Allows the caller to provide an up-to-date definition when necessary, e.g. the simulator needs to run with the absolute latest version of a flow\r\n\r\nOne option would be something similar to `<script>` and `<style>` elements in HTML where they can be embedded resources, or linked resources.\r\n\r\n```json\r\n\"assets\": [\r\n  {\"type\": \"channel\", \"uuid\": \"7a3b...\", \"src\": \"http://rpd.io/as/flows/7a3b...\"},\r\n  {\"type\": \"flow\", \"uuid\": \"4af6...\", \"src\": \"http://rpd.io/as/flows/4af6...\"},\r\n  {\"type\": \"flow\", \"def\": {\r\n    \"uuid\": \"a9c6...\",\r\n    \"nodes\": [...]\r\n  }},\r\n]\r\n```\r\n\r\nSo in the simulator case, it would send flows as embedded definitions, but probably all real world use we would send just the links. Goflow would then be responsible for caching those definitions for X amount of time.\r\n\r\nIf we wanted to support longer caching we could give callers the ability to invalidate or update goflow's asset cache when they know something has changed, e.g. an `/assets` endpoint"},"comment":{"url":"https://api.github.com/repos/nyaruka/goflow/issues/comments/319656715","html_url":"https://github.com/nyaruka/goflow/issues/75#issuecomment-319656715","issue_url":"https://api.github.com/repos/nyaruka/goflow/issues/75","id":319656715,"user":{"login":"rowanseymour","id":675558,"avatar_url":"https://avatars0.githubusercontent.com/u/675558?v=4","gravatar_id":"","url":"https://api.github.com/users/rowanseymour","html_url":"https://github.com/rowanseymour","followers_url":"https://api.github.com/users/rowanseymour/followers","following_url":"https://api.github.com/users/rowanseymour/following{/other_user}","gists_url":"https://api.github.com/users/rowanseymour/gists{/gist_id}","starred_url":"https://api.github.com/users/rowanseymour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rowanseymour/subscriptions","organizations_url":"https://api.github.com/users/rowanseymour/orgs","repos_url":"https://api.github.com/users/rowanseymour/repos","events_url":"https://api.github.com/users/rowanseymour/events{/privacy}","received_events_url":"https://api.github.com/users/rowanseymour/received_events","type":"User","site_admin":false},"created_at":"2017-08-02T12:24:50Z","updated_at":"2017-08-02T12:24:50Z","body":"Something else to consider - maybe runs (and contacts?) can be assets sometimes. For example in the trigger flow action case - the caller will need to start a flow with a parent run which belongs to a different contact. It may make sense to model this as an asset because:\r\n\r\n- It's immutable for the new flow session\r\n- The engine shouldn't be sending it back in the session and the caller shouldn't be trying to sync it.\r\n\r\nThe way it might works is:\r\n\r\n1. The trigger flow action will return a `trigger_flow` (?) event which contains the UUID of the parent run.\r\n2. Caller will grab the output of that run (either immediately from the session output or RapidPro could do it later by loading `FlowRun.output`)\r\n3. Caller starts a new flow session with:\r\n    - That parent as an asset\r\n    - A start_flow event which specifies the parent by UUID"}}
{"actor":{"display_login":"rowanseymour"}}