operation.go

 1package dag
 2
 3import (
 4	"github.com/MichaelMure/git-bug/entity"
 5	"github.com/MichaelMure/git-bug/identity"
 6)
 7
 8// Operation is a piece of data defining a change to reflect on the state of an Entity.
 9// What this Operation or Entity's state looks like is not of the resort of this package as it only deals with the
10// data structure and storage.
11type Operation interface {
12	// Id return the Operation identifier
13	// Some care need to be taken to define a correct Id derivation and enough entropy in the data used to avoid
14	// collisions. Notably:
15	// - the Id of the first Operation will be used as the Id of the Entity. Collision need to be avoided across entities of the same type
16	//   (example: no collision within the "bug" namespace).
17	// - collisions can also happen within the set of Operations of an Entity. Simple Operation might not have enough
18	//   entropy to yield unique Ids (example: two "close" operation within the same second, same author).
19	// A common way to derive an Id will be to use the DeriveId function on the serialized operation data.
20	Id() entity.Id
21	// Validate check if the Operation data is valid
22	Validate() error
23	// Author returns the author of this operation
24	Author() identity.Interface
25}