mariadbadapter

package
v0.0.0-...-4aa7239 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: OSL-3.0 Imports: 8 Imported by: 0

Documentation

Index

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 New

func New(config *Config) *MariaDb

New returns a reference to a new 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 research 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). Episode and clip hash calculations are presumed to be deterministic. Thus, episode and clip hashes are only inserted; not updated. This is a means to an end, and may change in the future. Hashes are maintained for all researached clips and episodes, but "completed research" is only explicitly recorded for episode/clip pairs where the clip is found within the episode. If research is conducted for a clip/episode pair, and the clip is not found in the episode, the clip/episode pair is removed from the backlog, and not added to the completed research table. This is currently done to save space in the database since the vast majority of clip/episode pairs are non-matches. Researched but negative pairings can be inferred as pairs that are in neither the backlog table nor the completed table.

func (*MariaDbConnection) RenewResearchLease

func (m *MariaDbConnection) RenewResearchLease(leaseID uuid.UUID, expiration time.Time) error

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.

Jump to

Keyboard shortcuts

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