Documentation
¶
Overview ¶
package revent implement repeating events with a very flexible interval type.
Example intervals are:
- every day
- every second day
- every monday
- every second tuesday
- every first monday of a month
- every second tuesday of a month
- every first monday of every second month
This gives three categories of intervals:
- DayInterval: every [1..7] day, starting at [date]
- WeekInterval: every [1..] [weekday] of week
- MonthInterval: every [1..4] [weekday] a month
Index ¶
- Constants
- func GenerateEvents(repeatingEvent *RepeatingEvent, existingEvents []*event.Event, ...) ([]*event.NewEvent, error)
- func ID(id string) string
- func NewExpiredMemoryStore() *crud.MemoryStore[ExpiredState, ExpiredState, ExpiredStateFilter]
- func NewMemoryStore() *crud.MemoryStore[NewRepeatingEvent, RepeatingEvent, FindFilters]
- func ParseID(id string) (string, bool)
- func Router(service Service, authService auth.Service) func(chi.Router)
- type CreateOperation
- type DeleteOperation
- type ExpiredNotifier
- type ExpiredState
- type ExpiredStateFilter
- type ExpiredStateSqlStore
- type ExpiredStorer
- type FindFilters
- type Interval
- type IntervalType
- type NewRepeatingEvent
- type RepeatingEvent
- type Service
- type SortOrder
- type SqlStore
- func (s *SqlStore) Create(ctx context.Context, newRepeatingEvent *NewRepeatingEvent) (*RepeatingEvent, error)
- func (s *SqlStore) Delete(ctx context.Context, id string) error
- func (s *SqlStore) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*RepeatingEvent, int, error)
- func (s *SqlStore) FindByID(ctx context.Context, id string) (*RepeatingEvent, error)
- func (s *SqlStore) Update(ctx context.Context, repeatingEvent *RepeatingEvent) (*RepeatingEvent, error)
- type Storer
- type UpdateOperation
Constants ¶
const ( IntervalDay = IntervalType("day") IntervalWeek = IntervalType("week") IntervalMonth = IntervalType("month") )
const ( OrderAsc = SortOrder("ASC") OrderDesc = SortOrder("DESC") )
Possible values for SortOrder.
Variables ¶
This section is empty.
Functions ¶
func GenerateEvents ¶
func NewExpiredMemoryStore ¶
func NewExpiredMemoryStore() *crud.MemoryStore[ExpiredState, ExpiredState, ExpiredStateFilter]
func NewMemoryStore ¶
func NewMemoryStore() *crud.MemoryStore[NewRepeatingEvent, RepeatingEvent, FindFilters]
NewMemoryStore returns a new in memory store.
Types ¶
type CreateOperation ¶
type CreateOperation struct { RepeatingEvent *RepeatingEvent // contains filtered or unexported fields }
func NewCreateOperation ¶
func NewCreateOperation(repeatingEvent *RepeatingEvent, userID string) CreateOperation
func (CreateOperation) UserID ¶
func (o CreateOperation) UserID() string
type DeleteOperation ¶
type DeleteOperation struct { ID string // contains filtered or unexported fields }
func NewDeleteOperation ¶
func NewDeleteOperation(id string, userID string) DeleteOperation
func (DeleteOperation) UserID ¶
func (o DeleteOperation) UserID() string
type ExpiredNotifier ¶
type ExpiredNotifier struct {
// contains filtered or unexported fields
}
func NewExpiredNotifier ¶
func NewExpiredNotifier(expiredStore ExpiredStorer, reventStore Storer, eventStore event.Storer, notifier notification.Notifier) *ExpiredNotifier
func (*ExpiredNotifier) ConsumeOperation ¶
func (e *ExpiredNotifier) ConsumeOperation(op oqueue.Operation) error
func (*ExpiredNotifier) NotifyAction ¶
func (e *ExpiredNotifier) NotifyAction(ctx context.Context) error
type ExpiredState ¶
type ExpiredState struct {
RepeatingEventID string `db:"repeating_event_id"`
}
func (ExpiredState) Identifier ¶
func (e ExpiredState) Identifier() string
type ExpiredStateFilter ¶
type ExpiredStateFilter struct{}
type ExpiredStateSqlStore ¶
type ExpiredStateSqlStore struct { *crud.SqlStore[ExpiredState, ExpiredState, ExpiredStateFilter] // contains filtered or unexported fields }
func NewExpiredStateSqlStore ¶
func NewExpiredStateSqlStore(db *sqlx.DB, migrationService dbmigration.Service) (*ExpiredStateSqlStore, error)
type ExpiredStorer ¶
type ExpiredStorer = crud.Storer[ExpiredState, ExpiredState, ExpiredStateFilter]
type FindFilters ¶
type FindFilters struct { ID *string `json:"id,omitempty"` Deactivated *bool `json:"deactivated,omitempty"` Published *bool `json:"published,omitempty"` Parent *string `json:"parent,omitempty"` Name *string `json:"name,omitempty"` Organizers []string `json:"organizers,omitempty"` Location *string `json:"location,omitempty"` Location2 *string `json:"location2,omitempty"` Description *string `json:"description,omitempty"` Start *time.Time `json:"start,omitempty"` End *time.Time `json:"end,omitempty"` Tags []string `json:"tags,omitempty"` OwnedBy []string `json:"ownedBy,omitempty"` }
FindFilters defines the possible filters for the find method.
type Interval ¶
type Interval struct { // Type changes the meaning od Interval an WeekDay. Type IntervalType `json:"type" db:"type"` // Interval used for day, week and month Interval int `json:"interval" db:"interval"` // WeekDay is a week day, with a range of 0 (sunday) to 7 (saturday). WeekDay time.Weekday `json:"weekDay" db:"weekDay"` }
type IntervalType ¶
type IntervalType string
IntervalType defines the type of the interval (day, week or month)
type NewRepeatingEvent ¶
type NewRepeatingEvent struct { Name string `json:"name"` Organizers []string `json:"organizers"` Location string `json:"location"` Location2 string `json:"location2"` Description string `json:"description"` Intervals []Interval `json:"intervals"` Start time.Time `json:"start"` End time.Time `json:"end"` Tags []string `json:"tags"` Image string `json:"image"` OwnedBy []string `json:"ownedBy"` }
func (*NewRepeatingEvent) IsOwned ¶
func (r *NewRepeatingEvent) IsOwned(id string) bool
IsOwned returns true if the id is in the OwnedBy field.
type RepeatingEvent ¶
type RepeatingEvent struct { ID string `json:"id" db:"id"` Deactivated bool `json:"deactivated" db:"deactivated"` Name string `json:"name" db:"name"` Organizers []string `json:"organizers" db:"organizers"` Location string `json:"location" db:"location"` Location2 string `json:"location2" db:"location2"` Description string `json:"description" db:"description"` Intervals []Interval `json:"intervals" db:"intervals"` Start time.Time `json:"start" db:"start"` End time.Time `json:"end" db:"end"` Tags []string `json:"tags" db:"tags"` Image string `json:"image" db:"image"` OwnedBy []string `json:"ownedBy" db:"ownedBy"` }
func RepeatingEventFromNewRepeatingEvent ¶
func RepeatingEventFromNewRepeatingEvent(newRepeatingEvent *NewRepeatingEvent, id string) *RepeatingEvent
func (RepeatingEvent) Identifier ¶
func (r RepeatingEvent) Identifier() string
func (*RepeatingEvent) IsOwned ¶
func (r *RepeatingEvent) IsOwned(id string) bool
IsOwned returns true if the id is in the OwnedBy field.
type Service ¶
type Service interface { Storer GenerateEvents(ctx context.Context, id string, start, end time.Time) ([]*event.Event, error) }
-go:generate go run github.com/petergtz/pegomock/pegomock generate eintopf.info/service/revent Service --output=../../internal/mock/revent_service.go --package=mock --mock-name=RepeatingEventService
func NewAuthorizer ¶
NewAuthorizer returns a new role manager limiting access to the provided store.
type SqlStore ¶
type SqlStore struct {
// contains filtered or unexported fields
}
func NewSqlStore ¶
NewSqlStore returns a new sql db RepeatingEvent store.
func (*SqlStore) Create ¶
func (s *SqlStore) Create(ctx context.Context, newRepeatingEvent *NewRepeatingEvent) (*RepeatingEvent, error)
func (*SqlStore) Find ¶
func (s *SqlStore) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*RepeatingEvent, int, error)
func (*SqlStore) Update ¶
func (s *SqlStore) Update(ctx context.Context, repeatingEvent *RepeatingEvent) (*RepeatingEvent, error)
type Storer ¶
type Storer interface { Create(ctx context.Context, newEvent *NewRepeatingEvent) (*RepeatingEvent, error) Update(ctx context.Context, event *RepeatingEvent) (*RepeatingEvent, error) Delete(ctx context.Context, id string) error FindByID(ctx context.Context, id string) (*RepeatingEvent, error) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*RepeatingEvent, int, error) }
Storer defines a service for CRUD operations on the event model.
type UpdateOperation ¶
type UpdateOperation struct { RepeatingEvent *RepeatingEvent // contains filtered or unexported fields }
func NewUpdateOperation ¶
func NewUpdateOperation(repeatingEvent *RepeatingEvent, userID string) UpdateOperation
func (UpdateOperation) UserID ¶
func (o UpdateOperation) UserID() string