Documentation ¶
Index ¶
- type BaseRepository
- func (r *BaseRepository[T]) Create(_ context.Context, organizationID string, namespace string, id string, obj *T, ...) (err error)
- func (r *BaseRepository[T]) Delete(_ context.Context, organizationID string, namespace string, id string) error
- func (r *BaseRepository[T]) GetByID(ctx context.Context, organizationID string, namespace string, id string) (*T, error)
- func (r *BaseRepository[T]) GetByIDs(_ context.Context, organizationID string, namespace string, ids ...string) (res map[string]*T, err error)
- func (r *BaseRepository[T]) Query(_ context.Context, organizationID string, namespace string, ...) (res []*T, nextOffsetToken string, err error)
- func (r *BaseRepository[T]) Size(_ context.Context, organizationID string, namespace string) (int64, error)
- func (r *BaseRepository[T]) Update(_ context.Context, organizationID string, namespace string, id string, ...) (err error)
- type DataStore
- type Repository
- func NewGroupRepository(store DataStore) (Repository[types.Group], error)
- func NewHashIndexRepository(store DataStore) (Repository[domain.HashIndex], error)
- func NewOrganizationRepository(store DataStore) (Repository[types.Organization], error)
- func NewPermissionRepository(store DataStore) (Repository[types.Permission], error)
- func NewPrincipalRepository(store DataStore) (Repository[types.Principal], error)
- func NewRelationshipRepository(store DataStore) (Repository[types.Relationship], error)
- func NewResourceRepository(store DataStore) (Repository[types.Resource], error)
- func NewRoleRepository(store DataStore) (Repository[types.Role], error)
- type ResourceInstanceRepositoryFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRepository ¶
type BaseRepository[T any] struct { // contains filtered or unexported fields }
BaseRepository - provides default persistence
func NewBaseRepository ¶
func NewBaseRepository[T any]( store DataStore, baseTableName string, baseTableSuffix string, expiration time.Duration, builder domain.Factory[T], ) (*BaseRepository[T], error)
NewBaseRepository creates base repository
func (*BaseRepository[T]) Create ¶
func (r *BaseRepository[T]) Create( _ context.Context, organizationID string, namespace string, id string, obj *T, expiration time.Duration, ) (err error)
Create adds a new item in the database.
func (*BaseRepository[T]) GetByID ¶
func (r *BaseRepository[T]) GetByID( ctx context.Context, organizationID string, namespace string, id string, ) (*T, error)
GetByID - finds an object by id
func (*BaseRepository[T]) GetByIDs ¶
func (r *BaseRepository[T]) GetByIDs( _ context.Context, organizationID string, namespace string, ids ...string) (res map[string]*T, err error)
GetByIDs retrieves objects by ids
func (*BaseRepository[T]) Query ¶
func (r *BaseRepository[T]) Query( _ context.Context, organizationID string, namespace string, predicate map[string]string, lastOffsetToken string, limit int64) (res []*T, nextOffsetToken string, err error)
Query - queries data
type DataStore ¶
type DataStore interface { // CreateTable creates underlying table if needed. CreateTable( baseTableName string, baseTableSuffix string, ) (err error) // Size of records for tenant. Size( baseTableName string, baseTableSuffix string, tenant string, namespace string, ) (size int64, err error) // Get finds records by ids. Get( baseTableName string, baseTableSuffix string, tenant string, namespace string, ids ...string, ) (res map[string][]byte, err error) // Query searches records by predicates. Query( baseTableName string, baseTableSuffix string, tenant string, namespace string, predicate map[string]string, lastEvaluatedKeyStr string, limit int64, ) (res map[string][]byte, nextKeyStr string, err error) // Create adds a new record. Create( baseTableName string, baseTableSuffix string, tenant string, namespace string, id string, value []byte, expiration time.Duration) (err error) // Update changes existing record. Update( baseTableName string, baseTableSuffix string, tenant string, namespace string, id string, version int64, value []byte, expiration time.Duration) (err error) // Delete removes existing record. Delete( baseTableName string, baseTableSuffix string, tenant string, namespace string, id string, ) (err error) // ClearTable removes all records for tenant ClearTable( baseTableName string, baseTableSuffix string, tenant string, namespace string, ) (err error) }
DataStore interface
type Repository ¶
type Repository[T any] interface { // GetByIDs - finds objects matching ids. GetByIDs( ctx context.Context, organizationID string, namespace string, ids ...string, ) (map[string]*T, error) // GetByID - finds an object by id. GetByID( ctx context.Context, organizationID string, namespace string, id string, ) (*T, error) // Create - creates a new object. Create( ctx context.Context, organizationID string, namespace string, id string, obj *T, expiration time.Duration, ) error // Update - saves existing object. Update( ctx context.Context, organizationID string, namespace string, id string, version int64, obj *T, expiration time.Duration, ) error // Query - queries objects Query( ctx context.Context, organizationID string, namespace string, predicate map[string]string, offset string, limit int64, ) (res []*T, nextOffset string, err error) // Delete - remove the object Delete( ctx context.Context, organizationID string, namespace string, id string, ) error // Size of table Size( ctx context.Context, organizationID string, namespace string, ) (int64, error) }
func NewGroupRepository ¶
func NewGroupRepository( store DataStore, ) (Repository[types.Group], error)
NewGroupRepository creates repository for persisting groups
func NewHashIndexRepository ¶
func NewHashIndexRepository( store DataStore, ) (Repository[domain.HashIndex], error)
NewHashIndexRepository creates repository for indexes
func NewOrganizationRepository ¶
func NewOrganizationRepository( store DataStore, ) (Repository[types.Organization], error)
NewOrganizationRepository creates repository for persisting organization
func NewPermissionRepository ¶
func NewPermissionRepository( store DataStore, ) (Repository[types.Permission], error)
NewPermissionRepository creates repository for persisting permission
func NewPrincipalRepository ¶
func NewPrincipalRepository( store DataStore, ) (Repository[types.Principal], error)
NewPrincipalRepository creates repository for persisting principals
func NewRelationshipRepository ¶
func NewRelationshipRepository( store DataStore, ) (Repository[types.Relationship], error)
NewRelationshipRepository creates repository for persisting relationships
func NewResourceRepository ¶
func NewResourceRepository( store DataStore, ) (Repository[types.Resource], error)
NewResourceRepository creates repository for persisting resources
func NewRoleRepository ¶
func NewRoleRepository( store DataStore, ) (Repository[types.Role], error)
NewRoleRepository creates repository for persisting roles
type ResourceInstanceRepositoryFactory ¶
type ResourceInstanceRepositoryFactory interface {
CreateResourceInstanceRepository(resourceID string) (Repository[types.ResourceInstance], error)
}
ResourceInstanceRepositoryFactory helper
func NewResourceInstanceRepository ¶
func NewResourceInstanceRepository( store DataStore, expiration time.Duration, ) (ResourceInstanceRepositoryFactory, error)
NewResourceInstanceRepository creates repository for persisting resources instance