Documentation ¶
Index ¶
- Variables
- func GetCalendar(ctx context.Context, userID string, productID string, name string) (*ics.Calendar, error)
- func GetICSEvent(ctx context.Context, event *ElphiEvent) (*ics.VEvent, error)
- func GetMerkliste(ctx context.Context, userID string) ([]string, error)
- type CachedMerkliste
- func (m *CachedMerkliste) GetCalendar(ctx context.Context, userID string) (*ics.Calendar, error)
- func (m *CachedMerkliste) GetElphiEvent(ctx context.Context, eventID string) (*ElphiEvent, error)
- func (m *CachedMerkliste) GetICSEvent(ctx context.Context, event *ElphiEvent) (*ics.VEvent, error)
- func (m *CachedMerkliste) RegisterMetrics(variableLabels []string, staticLabels prometheus.Labels)
- func (m *CachedMerkliste) StartCacheExpiration()
- func (m *CachedMerkliste) StopCacheExpiration()
- type CalendarHandler
- type ElphiEvent
- type EventHandler
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidUserID indicates that the requested user ID is formatted // incorrectly or does not exist. ErrInvalidUserID = errors.New("invalid user id") // ErrInvalidEventID indicates that the requested event ID is formatted // incorrectly or does not exist. ErrInvalidEventID = errors.New("invalid event id") // ErrNoEvents indicates that an ics URL did return an empty calendar. ErrNoEvents = errors.New("invalid ics file (no events)") // ErrMultipleEvents indicates that an ics URL did return multiple events // instead of a single one. ErrMultipleEvents = errors.New("invalid ics file (multiple events)") )
The ErrorLogger is used to log errors.
Functions ¶
func GetCalendar ¶
func GetCalendar(ctx context.Context, userID string, productID string, name string) (*ics.Calendar, error)
GetCalendar creates an iCal calendar with all events from the merkliste of the user with the specified ID.
For a cached variant of this method see CachedMerkliste.
func GetICSEvent ¶
GetICSEvent fetches the iCal event for the specified event.
For a cached variant of this method see CachedMerkliste.
Types ¶
type CachedMerkliste ¶
type CachedMerkliste struct { TTL time.Duration EventCache *ttlcache.Cache[string, *ElphiEvent] ICSCache *ttlcache.Cache[string, *ics.VEvent] ProductID string Name string }
A CachedMerkliste provides a convenient interface to perform cached lookup of events on the Elbphilharmonie API.
func NewCachedMerkliste ¶
func NewCachedMerkliste(ttl time.Duration) *CachedMerkliste
NewCachedMerkliste creates a new CachedMerkliste with the specified cache TTL.
func (*CachedMerkliste) GetCalendar ¶
GetCalendar creates an iCal calendar with the merkliste events of the specified user. This works similarly to the GetCalendar function.
func (*CachedMerkliste) GetElphiEvent ¶
func (m *CachedMerkliste) GetElphiEvent(ctx context.Context, eventID string) (*ElphiEvent, error)
GetElphiEvent performs a cached request for the specified event. Behind the scenes this method uses the GetElphiEvent function.
func (*CachedMerkliste) GetICSEvent ¶
func (m *CachedMerkliste) GetICSEvent(ctx context.Context, event *ElphiEvent) (*ics.VEvent, error)
GetICSEvent performs a cached request for the specified ICS file. Behind the scenes this method uses the GetICSEvent function.
func (*CachedMerkliste) RegisterMetrics ¶
func (m *CachedMerkliste) RegisterMetrics(variableLabels []string, staticLabels prometheus.Labels)
RegisterMetrics adds caching metrics to the global prometheus registry.
func (*CachedMerkliste) StartCacheExpiration ¶
func (m *CachedMerkliste) StartCacheExpiration()
StartCacheExpiration begins the automatic cache expiration.
func (*CachedMerkliste) StopCacheExpiration ¶
func (m *CachedMerkliste) StopCacheExpiration()
StopCacheExpiration stops the automatic cache expiration.
type CalendarHandler ¶
type CalendarHandler struct { Prefix string Merkliste *CachedMerkliste }
CalendarHandler provides an HTTP endpoint for the merkliste calendar. This implements http.Handler.
func (*CalendarHandler) ServeHTTP ¶
func (h *CalendarHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP implements an iCal HTTP endpoint providing events from a merkliste.
type ElphiEvent ¶
type ElphiEvent struct { ID string `json:"evis_id"` Title string `json:"title_de"` Subtitle string `json:"subtitle_de"` Description string `json:"description_long_de"` Room string `json:"room_dispname"` ImageURL string `json:"image_url"` ImageCopyright string `json:"image_copyright_de"` WebsiteURL string `json:"website_url"` StartDate string `json:"date_start"` EndDate string `json:"date_end"` ModificationDate string `json:"modified_at"` URL string `json:"url"` HTML string `json:"item_html"` }
ElphiEvent corresponds to an event as returned by the Elbphilharmonie REST API.
func GetElphiEvent ¶
func GetElphiEvent(ctx context.Context, eventID string) (*ElphiEvent, error)
GetElphiEvent fetches the event with the specified ID from the Elbphilharmonie API.
For a cached variant of this method see CachedMerkliste.
type EventHandler ¶
type EventHandler struct { Prefix string Merkliste *CachedMerkliste }
EventHandler provides an HTTP endpoint for a calendar containing a single event. This implements http.Handler.
func (*EventHandler) ServeHTTP ¶
func (h *EventHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP implements an iCal HTTP endpoint providing single Elphi events.