Documentation ¶
Index ¶
- Constants
- Variables
- func GetGroupIdFromSession(r *http.Request) (gid int64, err error)
- func HandleError(w http.ResponseWriter, status int, uri string, err error)
- func HandleReply(w http.ResponseWriter, status int, j string)
- func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func NewLog(level Level, logfile string)
- func WrapRouterHandle(app newrelic.Application, handle httprouter.Handle) httprouter.Handle
- type ApiData
- type BoltService
- func (bs *BoltService) CloseNATS()
- func (bs *BoltService) ConfigureNATS(host, port, channel string)
- func (bs *BoltService) ConnectNATS() (err error)
- func (bs *BoltService) EnableLoadAll()
- func (bs *BoltService) GetGroup(id int64) (group Group, ok bool)
- func (bs *BoltService) GetImage(id int64) (image Image, ok bool)
- func (bs *BoltService) ListenForUpdates()
- func (bs *BoltService) LoadCacheUpdates() (err error)
- func (bs *BoltService) LoadFromDb(ds *DbService, txn newrelic.Transaction) (err error)
- func (bs *BoltService) PublishUpdate() (err error)
- func (bs *BoltService) ShowUpdates()
- func (bs *BoltService) StoreDbUpdates()
- func (bs *BoltService) UpdateFromCache()
- type ContentService
- type ContentSettings
- type DbService
- type DbSettings
- type Group
- type GroupMap
- type Image
- type ImageMap
- type ImagesGroups
- type ImagesGroupsMap
- type JwtPayload
- type Level
- type Logging
- type QueueMessage
- type ResponseMessage
- type User
- type UserMap
- type UserMessage
Constants ¶
View Source
const ( // Retries to wait for docker DB instance DbConnectRetries = 5 // NATS server NHost = "nats://localhost:4222" NSub = "update" )
Folders and credentials
Variables ¶
View Source
var GroupSegment = newrelic.DatastoreSegment{ Collection: "groups", Operation: "SELECT", ParameterizedQuery: makeQuery(Group{}, "FROM groups g"), }
View Source
var ImageGroupSegment = newrelic.DatastoreSegment{ Collection: "images_groups", Operation: "SELECT", ParameterizedQuery: makeQuery(ImagesGroups{}, "FROM images_groups ig"), }
View Source
var ImageSegment = newrelic.DatastoreSegment{ Collection: "images", Operation: "SELECT", ParameterizedQuery: makeQuery(Image{}, "FROM images i WHERE i.media IS NOT NULL"), }
View Source
var JwtKey = []byte{194, 164, 235, 6, 138, 248, 171, 239, 24, 216, 11, 22, 137, 199, 215, 133}
16-byte JSON Web Token encryption key
View Source
var SessionKey = []byte("something-very-secret")
Session key
View Source
var UserSegment = newrelic.DatastoreSegment{ Collection: "users", Operation: "SELECT", ParameterizedQuery: makeQuery(User{}, "FROM users u WHERE u.id = ?"), }
Functions ¶
func HandleError ¶
func HandleError(w http.ResponseWriter, status int, uri string, err error)
func HandleReply ¶
func HandleReply(w http.ResponseWriter, status int, j string)
func Index ¶
func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func WrapRouterHandle ¶
func WrapRouterHandle(app newrelic.Application, handle httprouter.Handle) httprouter.Handle
Types ¶
type ApiData ¶
type ApiData struct {
// contains filtered or unexported fields
}
Local data - most functions are methods of this
func (*ApiData) InitSessions ¶
func (data *ApiData) InitSessions()
func (*ApiData) NewRouter ¶
func (data *ApiData) NewRouter(cs ContentService, ds *DbService, app newrelic.Application) (router *httprouter.Router)
func (*ApiData) StartServer ¶
func (data *ApiData) StartServer()
type BoltService ¶
type BoltService struct { GroupMap GroupMap ImageMap ImageMap // contains filtered or unexported fields }
func (*BoltService) CloseNATS ¶
func (bs *BoltService) CloseNATS()
func (*BoltService) ConfigureNATS ¶
func (bs *BoltService) ConfigureNATS(host, port, channel string)
func (*BoltService) ConnectNATS ¶
func (bs *BoltService) ConnectNATS() (err error)
func (*BoltService) EnableLoadAll ¶
func (bs *BoltService) EnableLoadAll()
func (*BoltService) ListenForUpdates ¶
func (bs *BoltService) ListenForUpdates()
func (*BoltService) LoadCacheUpdates ¶
func (bs *BoltService) LoadCacheUpdates() (err error)
func (*BoltService) LoadFromDb ¶
func (bs *BoltService) LoadFromDb(ds *DbService, txn newrelic.Transaction) (err error)
func (*BoltService) PublishUpdate ¶
func (bs *BoltService) PublishUpdate() (err error)
func (*BoltService) ShowUpdates ¶
func (bs *BoltService) ShowUpdates()
func (*BoltService) StoreDbUpdates ¶
func (bs *BoltService) StoreDbUpdates()
func (*BoltService) UpdateFromCache ¶
func (bs *BoltService) UpdateFromCache()
type ContentService ¶
type ContentService interface { ConfigureNATS(host, port, channel string) ConnectNATS() (err error) CloseNATS() EnableLoadAll() GetGroup(id int64) (group Group, ok bool) GetImage(id int64) (image Image, ok bool) ListenForUpdates() LoadCacheUpdates() (err error) LoadFromDb(ds *DbService, txn newrelic.Transaction) (err error) PublishUpdate() (err error) ShowUpdates() StoreDbUpdates() UpdateFromCache() }
func NewContentService ¶
func NewContentService(boltFile, boltBucket string) ContentService
type ContentSettings ¶
type ContentSettings struct {
// contains filtered or unexported fields
}
type DbService ¶
type DbService struct {
// contains filtered or unexported fields
}
func NewDbService ¶
type DbSettings ¶
type DbSettings struct {
// contains filtered or unexported fields
}
type Group ¶
type Group struct { Id int64 `json:"id" db:"id"` Name string `json:"name" db:"name"` SessionSeconds *int64 `json:"sess_seconds" db:"sess_seconds"` ImagesGroupsMap ImagesGroupsMap `json:"-"` }
type Image ¶
type Image struct { Id int64 `json:"id" db:"id"` Width int `json:"width" db:"width"` Height int `json:"height" db:"height"` Url string `json:"url" db:"url"` Title *string `json:"title" db:"title"` Artist *string `json:"artist" db:"artist"` Gallery *string `json:"gallery" db:"gallery"` Organization *string `json:"organization" db:"organization"` }
Pointers to int/string to allow for 'null' value in JSON
type ImagesGroups ¶
type ImagesGroupsMap ¶
type JwtPayload ¶
type QueueMessage ¶
type QueueMessage struct {
Command string `json:"command"`
}
type ResponseMessage ¶
type User ¶
type User struct { Id int64 `json:"id" db:"id"` GroupId int64 `json:"group_id" db:"group_id"` Guid string `json:"guid" db:"guid"` FirstName string `json:"first_name" db:"first_name"` MiddleInit string `json:"middle_init" db:"middle_init"` LastName string `json:"last_name" db:"last_name"` Email string `json:"email" db:"email"` Addr string `json:"addr" db:"addr"` City string `json:"city" db:"city"` State string `json:"state" db:"state"` Zip string `json:"zip" db:"zip"` Gender string `json:"gender" db:"gender"` Status bool `json:"status" db:"status"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.