Documentation
¶
Overview ¶
identifiers contains strategies for converting concrete objects to store in Karte (actions and observations) into identities. There are two strategies in this package.
ProdStrategy -- Uses the current time and an entropy source. NaiveStrategy -- Has a global in-memory counter and produces entity1, entity2, ...
Index ¶
Constants ¶
const IDVersion = "zzzz"
The IDVersion must be four bytes long. Please record all previously used ID versions here. It must use the character set [A-Z0-9a-z].
- zzzz (current) - zzzy (next) - zzzx (next-next)
const VersionPrefixLength = 4
The first four bytes of a Karte action identifier are the version.
Variables ¶
This section is empty.
Functions ¶
func GetIDVersion ¶
GetIDVersion gets the id version from a serialized ID.
Types ¶
type Strategy ¶
type Strategy interface { // IDForAction takes an action and returns an ID. IDForAction(ctx context.Context, action *kartepb.Action) (string, error) // IDForObservation takes an observation and returns an ID. IDForObservation(ctx context.Context, observation *kartepb.Observation) (string, error) }
Strategy controls how to convert an entity or record into a UUID that is used as a datastore key.
func NewDefault ¶
func NewDefault() Strategy
NewDefault instantiates the default strategy, which is the production strategy.