models

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MetaBucket     = Bucket{0, 0, 0, 109}
	LinksBucket    = Bucket{240, 159, 148, 151}
	APIKeysBucket  = Bucket{240, 159, 148, 145}
	CampaignBucket = Bucket{240, 159, 142, 186}
)

Buckets in use by the models in rtnl.link (appropriate emojis in unicode)

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	ClientID   string    `msgpack:"client_id"`
	DerivedKey string    `msgpack:"derived_key"`
	Created    time.Time `msgpack:"created"`
	Modified   time.Time `msgpack:"modified"`
}

func (*APIKey) Key

func (m *APIKey) Key() []byte

func (*APIKey) MarshalValue

func (m *APIKey) MarshalValue() ([]byte, error)

func (*APIKey) UnmarshalValue

func (m *APIKey) UnmarshalValue(data []byte) error

type Bucket

type Bucket [4]byte

A bucket is a 4 byte prefix that allows us to determine the object type by the key.

func (Bucket) String

func (b Bucket) String() string

type Counts added in v1.2.0

type Counts struct {
	Links     uint64 `msgpack:"links"`
	Clicks    uint64 `msgpack:"clicks"`
	Campaigns uint64 `msgpack:"campaigns"`
}

func (*Counts) ToAPI added in v1.2.0

func (c *Counts) ToAPI() *api.ShortcrustInfo

type Model

type Model interface {
	Key() []byte
	MarshalValue() ([]byte, error)
	UnmarshalValue(data []byte) error
}

type ShortURL

type ShortURL struct {
	ID          uint64    `msgpack:"id"`
	URL         string    `msgpack:"url"`
	Title       string    `msgpack:"title"`
	Description string    `msgpack:"description"`
	Expires     time.Time `msgpack:"expires"`
	Visits      uint64    `msgpack:"visits"`
	Created     time.Time `msgpack:"created"`
	Modified    time.Time `msgpack:"modified"`
	CreatedBy   string    `msgpack:"created_by"`
	CampaignID  uint64    `msgpack:"campaign_id"`
	Campaigns   []uint64  `msgpack:"campaigns"`
}

ShortURL represents a shortened link and the location to redirect the user to. The ShortURL also contains a basic visit counter and other metadata like title and description to make things easier to read on the front-end.

A Campaign is a relationship between shortened URLs that have different marketing purposes. For example, we might shorten a webinar link then create campaign links for sendgrid, twitter, linkedin, etc. The purpose of the campaign is to identify what channels are performing best. In terms of the data structure, a short URL can either have a campaign id -- meaning it is a campaign link for another URL or it can have a list of campaigns, it's sublinks. Technically a tree-structure is possible, but in practice, short urls should have either campaign id or campaigns.

func (*ShortURL) Key

func (m *ShortURL) Key() []byte

func (*ShortURL) MarshalValue

func (m *ShortURL) MarshalValue() ([]byte, error)

func (*ShortURL) ToAPI

func (m *ShortURL) ToAPI() *api.ShortURL

Creates an api.ShortURL object and populates it with the fields from the model that can be populated directly. Note that URL and AltURL cannot be directly populated without a configuration object.

func (*ShortURL) UnmarshalValue

func (m *ShortURL) UnmarshalValue(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL