Documentation ¶
Index ¶
- type Config
- type MariaDb
- type MariaDbConnection
- func (m *MariaDbConnection) CreateResearchLease(newLeaseID *uuid.UUID, episode *contracts.EpisodeInfo, ...) error
- func (m *MariaDbConnection) GetHighestPriorityClipsForEpisode(episode *contracts.EpisodeInfo, clipLimit int) ([]*contracts.ClipInfo, error)
- func (m *MariaDbConnection) GetHighestPriorityEpisode() (*contracts.EpisodeInfo, error)
- func (m *MariaDbConnection) RecordCompletedResearch(completedResearchItem *contracts.CompletedResearchItem) error
- func (m *MariaDbConnection) RenewResearchLease(leaseID uuid.UUID, expiration time.Time) error
- func (m *MariaDbConnection) RevokeResearchLease(leaseID uuid.UUID) error
- func (m *MariaDbConnection) UpsertClipInfo(clipInfo *contracts.ClipInfo) error
- func (m *MariaDbConnection) UpsertEpisodeInfo(episodeInfo *contracts.EpisodeInfo) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Addr string DBName string User string MaxConnectionLifetime time.Duration MaxOpenConnections int MaxIdleConnections int }
Config is a configuration for a mariadb instance.
type MariaDb ¶
type MariaDb struct {
// contains filtered or unexported fields
}
MariaDb is an adapter that plugs into a mariadb instance.
func (*MariaDb) Connect ¶
func (m *MariaDb) Connect() (*MariaDbConnection, error)
Connect attempts to open a connection to the underlaying mariadb instance.
type MariaDbConnection ¶
type MariaDbConnection struct {
// contains filtered or unexported fields
}
MariaDbConnection represents a successful connection to a mariadb instance.
func (*MariaDbConnection) CreateResearchLease ¶
func (m *MariaDbConnection) CreateResearchLease(newLeaseID *uuid.UUID, episode *contracts.EpisodeInfo, clips []*contracts.ClipInfo, expiration time.Time) error
CreateResearchLease attempts to create a lease that is shared between the episode and all provided clips. This method will panic if clips is empty or nil. If there are no clips to lease for an episode, that should be handled without attempting to call this method.
func (*MariaDbConnection) GetHighestPriorityClipsForEpisode ¶
func (m *MariaDbConnection) GetHighestPriorityClipsForEpisode(episode *contracts.EpisodeInfo, clipLimit int) ([]*contracts.ClipInfo, error)
GetHighestPriorityClipsForEpisode identifies and returns the highest priority clips to be researched for given episode. The number of clips returned is limited to `clipLimit`. If no clips are available for the supplied episode, this returns nil, nil.
func (*MariaDbConnection) GetHighestPriorityEpisode ¶
func (m *MariaDbConnection) GetHighestPriorityEpisode() (*contracts.EpisodeInfo, error)
GetHighestPriorityEpisode identifies and returns the highest priority episode to be researched. If no episodes are available, this returns nil, nil.
func (*MariaDbConnection) RecordCompletedResearch ¶
func (m *MariaDbConnection) RecordCompletedResearch(completedResearchItem *contracts.CompletedResearchItem) error
RecordCompletedResearch inserts a reserach item. The system currently presumes that research is only assigned and conducted from the backlog (episodes/clip pairs that have not previously been researched). Submitting research for an episode/clip pair that has previously been researched is not supported, and will result in an error (though database integrity is maintained if this occurs).
func (*MariaDbConnection) RenewResearchLease ¶
RenewResearchLease updates the deadline for an existing lease. If the lease doesn't exist, no action is taken.
func (*MariaDbConnection) RevokeResearchLease ¶
func (m *MariaDbConnection) RevokeResearchLease(leaseID uuid.UUID) error
RevokeResearchLease removes the leases for all items assigned to the specified leaseID. If the leaseID doesn't exist, no action is taken.
func (*MariaDbConnection) UpsertClipInfo ¶
func (m *MariaDbConnection) UpsertClipInfo(clipInfo *contracts.ClipInfo) error
UpsertClipInfo inserts or updates clip info. If the clip already exists, it will be updated, but its InitialDateCurated value is ignored. If the clip does not already exist, both InitialDateCurated and LastDateCurated are evaluated, but the insert will fail and an error will be returned if LastDateCurated is earlier than InitialDateCurated.
func (*MariaDbConnection) UpsertEpisodeInfo ¶
func (m *MariaDbConnection) UpsertEpisodeInfo(episodeInfo *contracts.EpisodeInfo) error
UpsertEpisodeInfo inserts or updates episode info. If the episode already exists, it will be updated, but its InitialDateCurated value is ignored. If the episode does not already exist, both InitialDateCurated and LastDateCurated are evaluated, but the insert will fail and an error will be returned if LastDateCurated is earlier than InitialDateCurated.