Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound can be returned if storers can't find the requested resource.
Functions ¶
func GuildsCourses ¶
GuildsCourses searches for the enrolled courses of each guild. It writes directly to the given output map. Guilds that cannot be found will be set to nil.
func SortCoursesByName ¶
func SortCoursesByName(courses []Course)
SortCourses sorts the given list of courses alphabetically.
Types ¶
type Course ¶
Course represents a course with a service host string attached to it to identify its source.
type CourseStorer ¶
type CourseStorer interface { // Course gets a single course. Course(id lms.CourseID) (*Course, error) // Courses searches in bulk for the given output map of course IDs to // courses. Courses(out map[lms.CourseID]Course) error // UpsertCourses updates or inserts the given list of courses into the // database. UpsertCourses(courses ...Course) error }
CourseStorer stores an internal database state of known courses.
type Guild ¶
type Guild struct { ID discord.GuildID // RoleMap maps each course to its appropriate role. RoleMap map[lms.CourseID]discord.RoleID }
Guild contains per-guild relationships.
type GuildStorer ¶
type GuildStorer interface { // Guild gets a guild. Guild(id discord.GuildID) (*Guild, error) // AddCourses adds courses into the guild wherein each course must be mapped // to a role. The courses must already be added into the database through // CourseStorer. SetCourses(guild discord.GuildID, roleMap map[lms.CourseID]discord.RoleID) error }
GuildStorer stores guild relationships and states.
type Store ¶
type Store struct { Users UserStorer Guilds GuildStorer Courses CourseStorer }
Store contains database store interfaces. These store interfaces may optionally implement io.Closer.
type User ¶
type User struct { ID discord.UserID // Services is the list of services that the user has previously synced // with. Services []UserInService }
User describes per-user data and relationships. Note that a user does not have to be guild-specific.
type UserInService ¶
type UserInService struct { lms.User // Enrolled contains a list of course IDs that the user is enrolled in. Enrolled []lms.CourseID // ServiceHost is the service host that this information is from. ServiceHost lms.Host // LastSynced is the last time this information was synced. LastSynced time.Time }
UserInService describes the user in a service.
type UserStorer ¶
type UserStorer interface { // User gets a user. User(id discord.UserID) (*User, error) // Sync synchronizes the given list of courses and the user information from // the service with the database. Sync(id discord.UserID, svc UserInService) error }
UserStorer stores an internal database of users and their relationships.