Documentation
¶
Index ¶
- Variables
- func ActivityID(target Target, day string) string
- func Validate(d Document) error
- func ValidateActivity(d ActivitySnapshot) error
- type ActivityEvent
- type ActivityFilter
- type ActivitySnapshot
- type Config
- type Document
- type Event
- type Filter
- type Item
- type Page
- type Repository
- type Service
- func (s *Service) Consume(ctx context.Context, e Event) error
- func (s *Service) ConsumeActivity(ctx context.Context, e ActivityEvent) error
- func (s *Service) MyVotes(ctx context.Context, user, cursor string, limit int) (Votes, error)
- func (s *Service) Popular(ctx context.Context, user, kind, cursor string, limit int) (Page, error)
- func (s *Service) Rebuild(ctx context.Context) error
- func (s *Service) Search(ctx context.Context, user, q, kind, cursor string, limit int) (Page, error)
- type Sources
- type Target
- type Vote
- type Votes
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ActivityID ¶
ActivityID is independent of provider; the database key includes Source.
func ValidateActivity ¶
func ValidateActivity(d ActivitySnapshot) error
Types ¶
type ActivityEvent ¶
type ActivityFilter ¶
type ActivitySnapshot ¶
type ActivitySnapshot struct {
Source string `json:"source"`
ID string `json:"id"`
Target Target `json:"target"`
Day string `json:"day"`
Revision int64 `json:"revision"`
Visible bool `json:"visible"`
Metrics map[string]int64 `json:"metrics"`
}
ActivitySnapshot is one provider's complete daily counters for one canonical object. Missing providers contribute zero. Metrics are never transferred between providers.
type Document ¶
type Document struct {
Code string `json:"code,omitempty"`
Aliases []string `json:"aliases,omitempty"`
Target Target `json:"target"`
Revision int64 `json:"revision"`
Title string `json:"title"`
SchoolID string `json:"school_id"`
Visible bool `json:"visible"`
CourseID string `json:"course_id,omitempty"`
TeacherIDs []string `json:"teacher_ids,omitempty"`
At time.Time `json:"at"`
}
Document is a source-owned public projection snapshot, never review body or identity data.
type Repository ¶
type Repository interface {
Apply(context.Context, Event, string) error
Candidates(context.Context, Filter) ([]Document, error)
// Rebuild holds the projection write lock and atomically publishes all source snapshots.
Rebuild(context.Context, func(func([]Document) error, func([]ActivitySnapshot) error) error) error
ApplyActivity(context.Context, ActivityEvent, string) error
Activities(context.Context, ActivityFilter) ([]ActivitySnapshot, error)
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) ConsumeActivity ¶
func (s *Service) ConsumeActivity(ctx context.Context, e ActivityEvent) error
type Sources ¶
type Sources interface {
Current(context.Context, string, Target) (Document, bool, error)
// DiscoverySnapshot returns at most limit records, including tombstones, using a consistent source snapshot.
// A nonempty cursor must advance. Empty next marks the end. Disabled sources return ErrSourceDisabled.
DiscoverySnapshot(context.Context, string, string, int) ([]Document, string, error)
ActivitySnapshot(context.Context, string, time.Time, time.Time, string, int) ([]ActivitySnapshot, string, error)
CurrentActivity(context.Context, string, string, string) (ActivitySnapshot, bool, error)
MyVotes(context.Context, string, string, int) (Votes, error)
}
Sources must use module public APIs and the authenticated principal. Never read source tables. Current returns current readable metadata; false includes deletion, withdrawal and revoked access.
Click to show internal directories.
Click to hide internal directories.