Documentation ¶
Index ¶
Constants ¶
const BoltDBFile = "tickets.db"
BoltDBFile is the filename to store the boltdb database
const BucketName = "tickets"
BucketName is the bucket name to store the tickets on the bolt db
const TicketHeader = "x-bitmaelum-ticket"
TicketHeader is the HTTP Header that contains our ticket ID when sending messages
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository interface { Fetch(ticketID string) (*Ticket, error) Store(ticket *Ticket) error Remove(ticketID string) }
Repository is a ticket repository to fetch and store tickets
func NewBoltRepository ¶
func NewBoltRepository(dbpath string) Repository
NewBoltRepository initializes a new repository
func NewRedisRepository ¶
func NewRedisRepository(opts *redis.Options) Repository
NewRedisRepository initializes a new repository
type Ticket ¶
type Ticket struct { ID string // ticket ID Valid bool // true if the ticket is valid Expiry time.Time // Time when this ticket expires Work *WorkType // Work that needs to be done for validating the ticket Sender hash.Hash // From address for this ticket Recipient hash.Hash // To address for this ticket SubscriptionID string // mailing list subscription ID (if any) AuthKey string // Optional authkey attached to the ticket in case its send on behalf }
Ticket is a structure that defines if a client or server is allowed to upload a message, or if additional work has to be done first
func NewFromBytes ¶
NewFromBytes will generate a ticket from the json-encoded data
func (*Ticket) MarshalBinary ¶
MarshalBinary converts a ticket to binary format so it can be stored in Redis
func (*Ticket) UnmarshalBinary ¶
UnmarshalBinary converts binary to a ticket so it can be fetched from Redis
type WorkType ¶
type WorkType struct { Type string // Type of work Data work.Repository // Work stored on this ticket }
WorkType is a structure that holds the type and work repository data
func (*WorkType) UnmarshalJSON ¶
UnmarshalJSON We unmarshal from the ticketWorkType, as we do not know which repository implementation we need. However, we can marshal from the implementation. This is why there is no MarshalJSON present here.