Documentation
¶
Index ¶
- Variables
- func NewConnection(config *gormpg.Conf) (*gorm.DB, error)
- func Seed(db *gorm.DB) error
- type AuthzFilterApplier
- type FilterFieldApplier
- type GormAgentRepository
- func (r *GormAgentRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
- func (r *GormAgentRepository) CountByProvider(ctx context.Context, providerID properties.UUID) (int64, error)
- func (r *GormAgentRepository) FindByServiceTypeAndTags(ctx context.Context, serviceTypeID properties.UUID, tags []string) ([]*domain.Agent, error)
- func (r *GormAgentRepository) MarkInactiveAgentsAsDisconnected(ctx context.Context, inactiveDuration time.Duration) (int64, error)
- type GormAgentTypeRepository
- type GormEventRepository
- func (r *GormEventRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
- func (r *GormEventRepository) ListFromSequence(ctx context.Context, fromSequenceNumber int64, limit int) ([]*domain.Event, error)
- func (r *GormEventRepository) ServiceUptime(ctx context.Context, serviceID properties.UUID, start time.Time, end time.Time) (uptimeSeconds uint64, downtimeSeconds uint64, err error)
- type GormEventSubscriptionRepository
- func (r *GormEventSubscriptionRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
- func (r *GormEventSubscriptionRepository) DeleteBySubscriberID(ctx context.Context, subscriberID string) error
- func (r *GormEventSubscriptionRepository) ExistsBySubscriberID(ctx context.Context, subscriberID string) (bool, error)
- func (r *GormEventSubscriptionRepository) FindBySubscriberID(ctx context.Context, subscriberID string) (*domain.EventSubscription, error)
- func (r *GormEventSubscriptionRepository) ListExpiredLeases(ctx context.Context) ([]*domain.EventSubscription, error)
- type GormJobRepository
- func (r *GormJobRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
- func (r *GormJobRepository) DeleteOldCompletedJobs(ctx context.Context, olderThan time.Duration) (int, error)
- func (r *GormJobRepository) GetPendingJobsForAgent(ctx context.Context, agentID properties.UUID, limit int) ([]*domain.Job, error)
- func (r *GormJobRepository) GetTimeOutJobs(ctx context.Context, olderThan time.Duration) ([]*domain.Job, error)
- type GormMetricEntryRepository
- func (r *GormMetricEntryRepository) Aggregate(ctx context.Context, aggregateType domain.AggregateType, ...) (float64, error)
- func (r *GormMetricEntryRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
- func (r *GormMetricEntryRepository) CountByMetricType(ctx context.Context, typeID properties.UUID) (int64, error)
- type GormMetricTypeRepository
- type GormParticipantRepository
- type GormRepository
- func (r *GormRepository[T]) AuthScopeByFields(ctx context.Context, id properties.UUID, scopeFields ...string) (auth.ObjectScope, error)
- func (r *GormRepository[T]) Count(ctx context.Context) (int64, error)
- func (r *GormRepository[T]) Create(ctx context.Context, entity *T) error
- func (r *GormRepository[T]) Delete(ctx context.Context, id properties.UUID) error
- func (r *GormRepository[T]) Exists(ctx context.Context, id properties.UUID) (bool, error)
- func (r *GormRepository[T]) Get(ctx context.Context, id properties.UUID) (*T, error)
- func (r *GormRepository[T]) List(ctx context.Context, authIdentityScope *auth.IdentityScope, ...) (*domain.PageRes[T], error)
- func (r *GormRepository[T]) Save(ctx context.Context, entity *T) error
- type GormServiceGroupRepository
- type GormServiceRepository
- func (r *GormServiceRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
- func (r *GormServiceRepository) CountByAgent(ctx context.Context, agentID properties.UUID) (int64, error)
- func (r *GormServiceRepository) CountByGroup(ctx context.Context, groupID properties.UUID) (int64, error)
- func (r *GormServiceRepository) FindByExternalID(ctx context.Context, agentID properties.UUID, externalID string) (*domain.Service, error)
- type GormServiceTypeRepository
- type GormStore
- func (s *GormStore) AgentRepo() domain.AgentRepository
- func (s *GormStore) AgentTypeRepo() domain.AgentTypeRepository
- func (s *GormStore) Atomic(ctx context.Context, fn func(domain.Store) error) error
- func (s *GormStore) EventRepo() domain.EventRepository
- func (s *GormStore) EventSubscriptionRepo() domain.EventSubscriptionRepository
- func (s *GormStore) JobRepo() domain.JobRepository
- func (s *GormStore) MetricEntryRepo() domain.MetricEntryRepository
- func (s *GormStore) MetricTypeRepo() domain.MetricTypeRepository
- func (s *GormStore) ParticipantRepo() domain.ParticipantRepository
- func (s *GormStore) ServiceGroupRepo() domain.ServiceGroupRepository
- func (s *GormStore) ServiceRepo() domain.ServiceRepository
- func (s *GormStore) ServiceTypeRepo() domain.ServiceTypeRepository
- func (s *GormStore) TokenRepo() domain.TokenRepository
- type GormTokenAuthenticator
- type GormTokenRepository
- func (r *GormTokenRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
- func (r *GormTokenRepository) DeleteByAgentID(ctx context.Context, agentID properties.UUID) error
- func (r *GormTokenRepository) DeleteByParticipantID(ctx context.Context, participantID properties.UUID) error
- func (r *GormTokenRepository) FindByHashedValue(ctx context.Context, hashedValue string) (*domain.Token, error)
- type PageFilterApplier
- type Tabler
- type TestDB
Constants ¶
This section is empty.
Variables ¶
var ( ErrTokenExpired = errors.New("token is expired") ErrTokenNotFound = errors.New("token not found") )
Functions ¶
func NewConnection ¶
NewConnection creates a new database connection
Types ¶
type AuthzFilterApplier ¶
type FilterFieldApplier ¶
func ParserInFilterFieldApplier ¶
func ParserInFilterFieldApplier[T any](f string, t func(string) (T, error)) FilterFieldApplier
func StringInFilterFieldApplier ¶
func StringInFilterFieldApplier(f string) FilterFieldApplier
type GormAgentRepository ¶
type GormAgentRepository struct {
*GormRepository[domain.Agent]
}
func NewAgentRepository ¶
func NewAgentRepository(db *gorm.DB) *GormAgentRepository
NewAgentRepository creates a new instance of AgentRepository
func (*GormAgentRepository) AuthScope ¶
func (r *GormAgentRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
AuthScope returns the auth scope for the agent
func (*GormAgentRepository) CountByProvider ¶
func (r *GormAgentRepository) CountByProvider(ctx context.Context, providerID properties.UUID) (int64, error)
func (*GormAgentRepository) FindByServiceTypeAndTags ¶
func (r *GormAgentRepository) FindByServiceTypeAndTags(ctx context.Context, serviceTypeID properties.UUID, tags []string) ([]*domain.Agent, error)
func (*GormAgentRepository) MarkInactiveAgentsAsDisconnected ¶
type GormAgentTypeRepository ¶
type GormAgentTypeRepository struct {
*GormRepository[domain.AgentType]
}
func NewAgentTypeRepository ¶
func NewAgentTypeRepository(db *gorm.DB) *GormAgentTypeRepository
NewAgentTypeRepository creates a new instance of AgentTypeRepository
func (*GormAgentTypeRepository) AuthScope ¶
func (r *GormAgentTypeRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
AuthScope returns the auth scope for the agent type
type GormEventRepository ¶
type GormEventRepository struct {
*GormRepository[domain.Event]
}
func NewEventRepository ¶
func NewEventRepository(db *gorm.DB) *GormEventRepository
NewEventRepository creates a new instance of EventRepository
func (*GormEventRepository) AuthScope ¶
func (r *GormEventRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
func (*GormEventRepository) ListFromSequence ¶
func (r *GormEventRepository) ListFromSequence(ctx context.Context, fromSequenceNumber int64, limit int) ([]*domain.Event, error)
ListFromSequence retrieves events starting from a specific sequence number
func (*GormEventRepository) ServiceUptime ¶
func (r *GormEventRepository) ServiceUptime(ctx context.Context, serviceID properties.UUID, start time.Time, end time.Time) (uptimeSeconds uint64, downtimeSeconds uint64, err error)
ServiceUptime returns the uptime and downtime in seconds of a service in a given time range It streams service transition events and calculates uptime progressively using a result set
type GormEventSubscriptionRepository ¶
type GormEventSubscriptionRepository struct {
*GormRepository[domain.EventSubscription]
}
func NewEventSubscriptionRepository ¶
func NewEventSubscriptionRepository(db *gorm.DB) *GormEventSubscriptionRepository
NewEventSubscriptionRepository creates a new instance of EventSubscriptionRepository
func (*GormEventSubscriptionRepository) AuthScope ¶
func (r *GormEventSubscriptionRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
AuthScope returns the auth scope for the event subscription
func (*GormEventSubscriptionRepository) DeleteBySubscriberID ¶
func (r *GormEventSubscriptionRepository) DeleteBySubscriberID(ctx context.Context, subscriberID string) error
DeleteBySubscriberID removes an event subscription by subscriber ID
func (*GormEventSubscriptionRepository) ExistsBySubscriberID ¶
func (r *GormEventSubscriptionRepository) ExistsBySubscriberID(ctx context.Context, subscriberID string) (bool, error)
ExistsBySubscriberID checks if an event subscription exists by subscriber ID
func (*GormEventSubscriptionRepository) FindBySubscriberID ¶
func (r *GormEventSubscriptionRepository) FindBySubscriberID(ctx context.Context, subscriberID string) (*domain.EventSubscription, error)
FindBySubscriberID retrieves an event subscription by subscriber ID
func (*GormEventSubscriptionRepository) ListExpiredLeases ¶
func (r *GormEventSubscriptionRepository) ListExpiredLeases(ctx context.Context) ([]*domain.EventSubscription, error)
ListExpiredLeases retrieves subscriptions with expired leases
type GormJobRepository ¶
type GormJobRepository struct {
*GormRepository[domain.Job]
}
func NewJobRepository ¶
func NewJobRepository(db *gorm.DB) *GormJobRepository
NewJobRepository creates a new instance of JobRepository
func (*GormJobRepository) AuthScope ¶
func (r *GormJobRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
func (*GormJobRepository) DeleteOldCompletedJobs ¶
func (r *GormJobRepository) DeleteOldCompletedJobs(ctx context.Context, olderThan time.Duration) (int, error)
DeleteOldCompletedJobs removes completed or failed jobs older than the specified days
func (*GormJobRepository) GetPendingJobsForAgent ¶
func (r *GormJobRepository) GetPendingJobsForAgent(ctx context.Context, agentID properties.UUID, limit int) ([]*domain.Job, error)
GetPendingJobsForAgent retrieves pending jobs targeted for a specific agent Returns only one pending job per service group with the highest priority Excludes service groups that have any jobs currently in processing status
func (*GormJobRepository) GetTimeOutJobs ¶
func (r *GormJobRepository) GetTimeOutJobs(ctx context.Context, olderThan time.Duration) ([]*domain.Job, error)
GetTimeOutJobs retrieves jobs that have been processing for too long and returns them
type GormMetricEntryRepository ¶
type GormMetricEntryRepository struct {
*GormRepository[domain.MetricEntry]
}
func NewMetricEntryRepository ¶
func NewMetricEntryRepository(db *gorm.DB) *GormMetricEntryRepository
NewMetricEntryRepository creates a new instance of MetricEntryRepository
func (*GormMetricEntryRepository) Aggregate ¶
func (r *GormMetricEntryRepository) Aggregate(ctx context.Context, aggregateType domain.AggregateType, serviceID properties.UUID, typeID properties.UUID, start time.Time, end time.Time) (float64, error)
Aggregate performs aggregation operations on metric entries for a specific metric type and service within a time range
func (*GormMetricEntryRepository) AuthScope ¶
func (r *GormMetricEntryRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
func (*GormMetricEntryRepository) CountByMetricType ¶
func (r *GormMetricEntryRepository) CountByMetricType(ctx context.Context, typeID properties.UUID) (int64, error)
CountByMetricType counts the number of entries for a specific metric type
type GormMetricTypeRepository ¶
type GormMetricTypeRepository struct {
*GormRepository[domain.MetricType]
}
func NewMetricTypeRepository ¶
func NewMetricTypeRepository(db *gorm.DB) *GormMetricTypeRepository
NewMetricTypeRepository creates a new instance of MetricTypeRepository
func (*GormMetricTypeRepository) AuthScope ¶
func (r *GormMetricTypeRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
func (*GormMetricTypeRepository) FindByName ¶
func (r *GormMetricTypeRepository) FindByName(ctx context.Context, name string) (*domain.MetricType, error)
FindByName retrieves a metric type by name
type GormParticipantRepository ¶
type GormParticipantRepository struct {
*GormRepository[domain.Participant]
}
func NewParticipantRepository ¶
func NewParticipantRepository(db *gorm.DB) *GormParticipantRepository
NewParticipantRepository creates a new instance of ParticipantRepository
func (*GormParticipantRepository) AuthScope ¶
func (r *GormParticipantRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
AuthScope returns the auth scope for the participant
type GormRepository ¶
type GormRepository[T Tabler] struct { // contains filtered or unexported fields }
GormRepository provides a base implementation of Repository using GORM
func NewGormRepository ¶
func NewGormRepository[T Tabler]( db *gorm.DB, filterApplier PageFilterApplier, sortApplier PageFilterApplier, authzFilterApplier AuthzFilterApplier, findPreloadPaths []string, listPreloadPaths []string, ) *GormRepository[T]
NewGormRepository creates a new instance of GormRepository
func (*GormRepository[T]) AuthScopeByFields ¶
func (r *GormRepository[T]) AuthScopeByFields(ctx context.Context, id properties.UUID, scopeFields ...string) (auth.ObjectScope, error)
AuthScopeByFields retrieves auth scope for an entity with specified scope fields
func (*GormRepository[T]) Count ¶
func (r *GormRepository[T]) Count(ctx context.Context) (int64, error)
func (*GormRepository[T]) Create ¶
func (r *GormRepository[T]) Create(ctx context.Context, entity *T) error
func (*GormRepository[T]) Delete ¶
func (r *GormRepository[T]) Delete(ctx context.Context, id properties.UUID) error
func (*GormRepository[T]) Exists ¶
func (r *GormRepository[T]) Exists(ctx context.Context, id properties.UUID) (bool, error)
func (*GormRepository[T]) Get ¶
func (r *GormRepository[T]) Get(ctx context.Context, id properties.UUID) (*T, error)
type GormServiceGroupRepository ¶
type GormServiceGroupRepository struct {
*GormRepository[domain.ServiceGroup]
}
func NewServiceGroupRepository ¶
func NewServiceGroupRepository(db *gorm.DB) *GormServiceGroupRepository
NewServiceGroupRepository creates a new instance of ServiceGroupRepository
func (*GormServiceGroupRepository) AuthScope ¶
func (r *GormServiceGroupRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
func (*GormServiceGroupRepository) CountByService ¶
func (r *GormServiceGroupRepository) CountByService(ctx context.Context, serviceID properties.UUID) (int64, error)
CountByService returns the number of service groups associated with a specific service
type GormServiceRepository ¶
type GormServiceRepository struct {
*GormRepository[domain.Service]
}
func NewServiceRepository ¶
func NewServiceRepository(db *gorm.DB) *GormServiceRepository
NewServiceRepository creates a new instance of ServiceRepository
func (*GormServiceRepository) AuthScope ¶
func (r *GormServiceRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
func (*GormServiceRepository) CountByAgent ¶
func (r *GormServiceRepository) CountByAgent(ctx context.Context, agentID properties.UUID) (int64, error)
func (*GormServiceRepository) CountByGroup ¶
func (r *GormServiceRepository) CountByGroup(ctx context.Context, groupID properties.UUID) (int64, error)
func (*GormServiceRepository) FindByExternalID ¶
func (r *GormServiceRepository) FindByExternalID(ctx context.Context, agentID properties.UUID, externalID string) (*domain.Service, error)
FindByExternalID retrieves a service by its external ID and agent ID
type GormServiceTypeRepository ¶
type GormServiceTypeRepository struct {
*GormRepository[domain.ServiceType]
}
func NewServiceTypeRepository ¶
func NewServiceTypeRepository(db *gorm.DB) *GormServiceTypeRepository
NewServiceTypeRepository creates a new instance of ServiceTypeRepository
func (*GormServiceTypeRepository) AuthScope ¶
func (r *GormServiceTypeRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
AuthScope returns the auth scope for the service type
type GormStore ¶
type GormStore struct {
// contains filtered or unexported fields
}
GormStore implements the domain.Store interface using GORM
func NewGormStore ¶
NewGormStore creates a new GormStore instance
func (*GormStore) AgentRepo ¶
func (s *GormStore) AgentRepo() domain.AgentRepository
func (*GormStore) AgentTypeRepo ¶
func (s *GormStore) AgentTypeRepo() domain.AgentTypeRepository
func (*GormStore) EventRepo ¶
func (s *GormStore) EventRepo() domain.EventRepository
func (*GormStore) EventSubscriptionRepo ¶
func (s *GormStore) EventSubscriptionRepo() domain.EventSubscriptionRepository
func (*GormStore) JobRepo ¶
func (s *GormStore) JobRepo() domain.JobRepository
func (*GormStore) MetricEntryRepo ¶
func (s *GormStore) MetricEntryRepo() domain.MetricEntryRepository
func (*GormStore) MetricTypeRepo ¶
func (s *GormStore) MetricTypeRepo() domain.MetricTypeRepository
func (*GormStore) ParticipantRepo ¶
func (s *GormStore) ParticipantRepo() domain.ParticipantRepository
func (*GormStore) ServiceGroupRepo ¶
func (s *GormStore) ServiceGroupRepo() domain.ServiceGroupRepository
func (*GormStore) ServiceRepo ¶
func (s *GormStore) ServiceRepo() domain.ServiceRepository
func (*GormStore) ServiceTypeRepo ¶
func (s *GormStore) ServiceTypeRepo() domain.ServiceTypeRepository
func (*GormStore) TokenRepo ¶
func (s *GormStore) TokenRepo() domain.TokenRepository
type GormTokenAuthenticator ¶
type GormTokenAuthenticator struct {
// contains filtered or unexported fields
}
GormTokenAuthenticator implements domain.Authenticator using GORM database
func NewTokenAuthenticator ¶
func NewTokenAuthenticator(store domain.Store) *GormTokenAuthenticator
NewTokenAuthenticator creates a new token authenticator
func (*GormTokenAuthenticator) Authenticate ¶
func (a *GormTokenAuthenticator) Authenticate(ctx context.Context, tokenValue string) (*auth.Identity, error)
Authenticate extracts and validates the token from the HTTP request Returns nil if authentication fails
type GormTokenRepository ¶
type GormTokenRepository struct {
*GormRepository[domain.Token]
}
func NewTokenRepository ¶
func NewTokenRepository(db *gorm.DB) *GormTokenRepository
NewTokenRepository creates a new instance of TokenRepository
func (*GormTokenRepository) AuthScope ¶
func (r *GormTokenRepository) AuthScope(ctx context.Context, id properties.UUID) (auth.ObjectScope, error)
AuthScope returns the auth scope for the token
func (*GormTokenRepository) DeleteByAgentID ¶
func (r *GormTokenRepository) DeleteByAgentID(ctx context.Context, agentID properties.UUID) error
DeleteByAgentID removes all tokens associated with an agent ID
func (*GormTokenRepository) DeleteByParticipantID ¶
func (r *GormTokenRepository) DeleteByParticipantID(ctx context.Context, participantID properties.UUID) error
DeleteByParticipantID removes all tokens associated with a participant ID
func (*GormTokenRepository) FindByHashedValue ¶
func (r *GormTokenRepository) FindByHashedValue(ctx context.Context, hashedValue string) (*domain.Token, error)
FindByHashedValue finds a token by its hashed value
type PageFilterApplier ¶
func MapFilterApplier ¶
func MapFilterApplier(fields map[string]FilterFieldApplier) PageFilterApplier
func MapSortApplier ¶
func MapSortApplier(fields map[string]string) PageFilterApplier
Source Files
¶
- gorm_authenticator.go
- gorm_pagination.go
- gorm_postgres.go
- gorm_repo_agent.go
- gorm_repo_agent_type.go
- gorm_repo_base.go
- gorm_repo_event.go
- gorm_repo_event_subscription.go
- gorm_repo_job.go
- gorm_repo_metric_entry.go
- gorm_repo_metric_type.go
- gorm_repo_participant.go
- gorm_repo_service.go
- gorm_repo_service_group.go
- gorm_repo_service_type.go
- gorm_repo_token.go
- gorm_store.go
- gorm_test_db_helper.go
- gorm_test_utils.go
- seed.go