Glific v0.3.1 Glific.Flows.FlowContext View Source
When we are running a flow, we are running it in the context of a contact and/or a conversation (or other Glific data types). Let encapsulate this in a module and isolate the flow from the other aspects of Glific
Link to this section Summary
Functions
Check if there is an active context (i.e. with a non null, node_uuid for this contact)
Standard changeset pattern we use for all data types
Create a FlowContext
Execute one (or more) steps in a flow based on the message stream
Retrieve the value from a results string
Start a new context, if there is an existing context, blow it away
Load the context object, given a flow object and a contact. At some point, we'll get the genserver to cache this
Count the number of times we have sent the same message in the recent past
Resets the context and sends control back to the parent context if one exists
Set the new node for the context
Given an input string, consume the input and advance the state of the context
Update the recent_* state as we consume or send a message
Update the contact results with each element of the json map
Update the contact results state as we step through the flow
Find all the contexts which need to be woken up and processed
Link to this section Types
Specs
t() :: %Glific.Flows.FlowContext{ __meta__: Ecto.Schema.Metadata.t(), completed_at: :utc_datetime | nil, contact: Glific.Contacts.Contact.t() | Ecto.Association.NotLoaded.t() | nil, contact_id: non_neg_integer() | nil, delay: integer(), flow: Glific.Flows.Flow.t() | Ecto.Association.NotLoaded.t() | nil, flow_id: non_neg_integer() | nil, flow_uuid: Ecto.UUID.t() | nil, id: term(), inserted_at: :utc_datetime | nil, node: Glific.Flows.Node.t() | nil, node_uuid: Ecto.UUID.t() | nil, parent: t() | Ecto.Association.NotLoaded.t() | nil, parent_id: non_neg_integer() | nil, recent_inbound: [map()] | [], recent_outbound: [map()] | [], results: map() | nil, updated_at: :utc_datetime | nil, uuid_map: map() | nil, wakeup_at: :utc_datetime | nil }
Link to this section Functions
Specs
active_context(non_neg_integer(), non_neg_integer() | nil) :: t() | nil
Check if there is an active context (i.e. with a non null, node_uuid for this contact)
Specs
changeset(t(), map()) :: Ecto.Changeset.t()
Standard changeset pattern we use for all data types
Specs
create_flow_context(map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
Create a FlowContext
Specs
Execute one (or more) steps in a flow based on the message stream
Specs
Retrieve the value from a results string
Specs
init_context( Glific.Flows.Flow.t(), Glific.Contacts.Contact.t(), non_neg_integer() | nil, non_neg_integer() | 0 ) :: {:ok, t(), [String.t()]} | {:error, String.t()}
Start a new context, if there is an existing context, blow it away
Specs
load_context(t(), Glific.Flows.Flow.t()) :: t()
Load the context object, given a flow object and a contact. At some point, we'll get the genserver to cache this
Specs
match_outbound(t(), Ecto.UUID.t(), integer()) :: integer()
Count the number of times we have sent the same message in the recent past
Specs
Resets the context and sends control back to the parent context if one exists
Specs
set_node(t(), Glific.Flows.Node.t()) :: t()
Set the new node for the context
Specs
Given an input string, consume the input and advance the state of the context
Specs
Update the recent_* state as we consume or send a message
Specs
Update the contact results with each element of the json map
Specs
Update the contact results state as we step through the flow
Specs
wakeup() :: [t()]
Find all the contexts which need to be woken up and processed