Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicateGrant = errors.New("duplicate (subject, object, kind) in the batch")
ErrDuplicateGrant means a batch held two grants with the same (Subject, Object, Kind). The partial unique index allows one DIRECT role per grant, so the upsert touches a row twice and the DB rejects it; the handler maps this to InvalidArgument.
var ErrNoObjects = errors.New("store: read requires at least one object")
ErrNoObjects means a read was requested without any object to scope it to.
Functions ¶
Types ¶
type Kind ¶
type Kind int32
Kind mirrors relationshipspb.Kind but keeps this package free of a proto dependency; the handler maps the proto enum onto it.
type Relationship ¶
type Relationship struct {
Subject uuid.UUID
Object uuid.UUID
Kind Kind
// EdgeType is the stored edge class (1=DIRECT). This API only writes DIRECT
// rows; it is mapped through so the struct mirrors the row for future readers.
EdgeType int32
Role uuid.UUID
CreatedAt time.Time
}
func BatchUpsert ¶ added in v1.14.0
func BatchUpsert(ctx context.Context, tx storage.Transaction, grants []Grant) ([]Relationship, error)
BatchUpsert writes every grant in one statement and returns the stored rows in the same order as grants. A batch must not contain two grants with the same (Subject, Object, Kind); the DB rejects that and BatchUpsert returns ErrDuplicateGrant. It writes, so it takes the transaction it runs in.