Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ID ¶
ID generates a stable identifier based on the given ID tags.
The identifier is generated by creating a SHA256 hash of the concatenated key-value pairs of the tags, sorted by key to ensure consistent ordering. The resulting hash is returned as a types.Binary value.
The implementation of this function must remain stable to not break existing object references in the database. Any changes to the algorithm must be carefully considered and documented, as they may affect the integrity of existing data.
Types ¶
type IdTagRow ¶
type IdTagRow struct {
ObjectId types.Binary `db:"object_id"`
Tag string `db:"tag"`
Value string `db:"value"`
}
IdTagRow represents a single database object id tag.
type Object ¶
type Object struct {
ID types.Binary `db:"id"`
Name string `db:"name"`
URL types.String `db:"url"`
Tags map[string]string `db:"-"`
// Sources is populated with the display names of every Source that has ever reported an event for this Object.
Sources []string `db:"-"`
}
func SyncFromEvent ¶ added in v1.0.0
func SyncFromEvent(ctx context.Context, db *database.DB, tx *sqlx.Tx, ev *event.Event) (*Object, error)
SyncFromEvent syncs the object in the database with the given event.
It inserts or updates the object and its tags in the database based on the provided event. The function uses the specified tx to ensure that both the object and its tags are updated atomically.
Returns error on any database failure, otherwise returns the updated object.