object

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: GPL-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ID

func ID(tags map[string]string) types.Binary

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.

func Sources added in v1.0.0

func Sources(ctx context.Context, db *database.DB, id types.Binary) ([]string, error)

Sources returns the names of every source that has ever reported an event for the given object.

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.

func (*IdTagRow) TableName

func (e *IdTagRow) TableName() string

TableName implements the contracts.TableNamer interface.

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 Get added in v1.0.0

func Get(ctx context.Context, db *database.DB, id types.Binary) (*Object, error)

Get the Object for the requested ID from the database.

func New

func New(ev *event.Event) *Object

New creates a new object from the given event.

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.

func (*Object) Upsert

func (o *Object) Upsert() any

Upsert implements the contracts.Upserter interface.

type Source added in v1.0.0

type Source struct {
	ObjectID types.Binary `db:"object_id"`
	SourceID int64        `db:"source_id"`
}

Source represents the association between an object and a source.

func (*Source) TableName added in v1.0.0

func (*Source) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL