The GroupByActor
is a technical Coral Actor that can partition an event stream based on unique values of an input field. The GroupByActor
will relay messages to the correct actor, depending on the value of the input field, and will create a child actor for values that it did not see before.
The GroupByActor
is not created directly. If an actor that supports grouping has the group by field specified in its constructor, a GroupByActor will be created. The GroupByActor
will redirect the object to the correct actor for distinct values of the group by field.
{
"data": {
"type": "actors",
"attributes": {
"type": "stats",
"params": {
"field": "amount"
},
"group": {
"by": "tag"
}
}
}
}
In this example, a StatsActor
is being created partitioned by the field ‘tag’. The Coral platform creates a GroupByActor
, and waits for distinct values of the ‘tag’ field. An actual instance of the StatsActor
is only created when a ‘tag’ field comes along containing a new value that was not encountered before.
The GroupByActor
reads the value of the group by field from the trigger JSON. If such a field is found, the JSON will be relayed as trigger for the corresponding underlying actor. For a newly encountered value a new actor will be created. If the group by field is not found, nothing is done.
The GroupByActor
does not emit anything itself. However, underlying actors may emit.
The GroupByActor
does not keep state. However, if underlying actors do keep state, this state can be collected from the GroupByActor
.
The GroupByActor
does not collect state from other actors. The underlying actors however may do so.
The GroupByActor
does not itself have a timer function implemented. The underlying actors, however, can have timer functions.