Documentation
¶
Index ¶
Constants ¶
const (
// LeesahTimeformat is Python's time format for Leesah messages, which is a form of RFC3339
LeesahTimeformat = "2006-01-02T15:04:05.999999"
)
Variables ¶
This section is empty.
Functions ¶
func NewLocalRapid ¶
func NewLocalRapid(teamName string, log *slog.Logger, ignoredCategories []QuestionCategory) (*rapid, error)
NewLocalRapid creates a new Rapid instance with a local configuration. The local configuration is read from "leesah-certs.yaml". It is used when playing the local edition of Leesah. You can override the path to the local certification by setting the environment variable QUIZ_CERTS. You can also override the topic by setting the environment variable QUIZ_TOPIC, or else the first topic in the file will be used.
func NewRapid ¶
func NewRapid(teamName string, config RapidConfig) (*rapid, error)
NewRapid creates a new Rapid instance with the given configuration. It is used when playing the Nais-edition of Leesah.
Types ¶
type Message ¶
type Message struct { Answer string `json:"svar"` Category QuestionCategory `json:"kategorinavn"` Created string `json:"@opprettet"` AnswerID string `json:"svarId"` Question string `json:"spørsmål,omitempty"` QuestionID string `json:"spørsmålId"` AnswerFormat string `json:"svarformat,omitempty"` TeamName string `json:"lagnavn"` Type MessageType `json:"@event_name"` }
Message is a struct that represents a message in the Leesah Kafka topic
func (Message) ToQuestion ¶
ToQuestion converts a Message to a simpler Question model
type MessageType ¶
type MessageType string
MessageType is an enum for the type of message in the Leesah Kafka topic
const ( MessageTypeQuestion MessageType = "SPØRSMÅL" MessageTypeAnswer = "SVAR" )
type Question ¶
type Question struct { Category QuestionCategory Question string AnswerFormat string }
Question is a simplified version of a Message with just the category, question, and answer format
type QuestionCategory ¶ added in v0.4.0
type QuestionCategory string
QuestionCategory is an enum for the category of a question in the Leesah Kafka topic
const ( TeamRegistration QuestionCategory = "team-registration" Aritmetikk QuestionCategory = "aritmetikk" Bankkonto QuestionCategory = "bankkonto" Base64 QuestionCategory = "base64" Deduplication QuestionCategory = "deduplication" Grunnbeløp QuestionCategory = "grunnbeløp" MinMax QuestionCategory = "min-max" PingPong QuestionCategory = "ping-pong" Primtall QuestionCategory = "primtall" NAV QuestionCategory = "NAV" )
type RapidConfig ¶
type RapidConfig struct { Broker string CAPath string CertPath string GroupID string IgnoredCategories []QuestionCategory KafkaDir string Log *slog.Logger PrivateKeyPath string Topic string }
RapidConfig is a struct that represents the configuration for a Rapid instance This is used when creating a new Rapid instance on the NAIS platform