storage

package
v0.0.0-...-a426365 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const CALLBACK_COLLECTION = "internal_callbacks"
View Source
const CONFIG_COLLECTION = "channel_configs"

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelConfig

type ChannelConfig struct {
	ChannelID      string
	ChannelName    string
	Project        string
	Components     []string
	AssignEndpoint string
}

type Collection

type Collection interface {
	Find(query interface{}) *mgo.Query
	Count() (n int, err error)
	FindId(id interface{}) *mgo.Query
	Insert(docs ...interface{}) error
	Remove(selector interface{}) error
	Update(selector interface{}, update interface{}) error
	Upsert(selector interface{}, update interface{}) (info *mgo.ChangeInfo, err error)
	UpsertId(id interface{}, update interface{}) (info *mgo.ChangeInfo, err error)
	EnsureIndex(index mgo.Index) error
	RemoveAll(selector interface{}) (info *mgo.ChangeInfo, err error)
}

type DataLayer

type DataLayer interface {
	C(name string) Collection
	SetChannelProject(channelID string, project string) error
	SetChannelConfig(config *ChannelConfig) error
	GetChannelConfig(channelID string) (*ChannelConfig, error)
	StoreCallback(callbackID string, command *SlashCommand) error
	RemoveCallback(callbackID string) error
	RemoveStaleCallbacks(timeout int64) error
	GetCallback(callbackID string) (*SlashCommand, error)
}

type MongoCollection

type MongoCollection struct {
	*mgo.Collection
}

type MongoDatabase

type MongoDatabase struct {
	*mgo.Database
}

func (MongoDatabase) C

func (d MongoDatabase) C(name string) Collection

func (*MongoDatabase) GetCallback

func (db *MongoDatabase) GetCallback(callbackID string) (*SlashCommand, error)

func (*MongoDatabase) GetChannelConfig

func (db *MongoDatabase) GetChannelConfig(channelID string) (*ChannelConfig, error)

func (*MongoDatabase) RemoveCallback

func (db *MongoDatabase) RemoveCallback(callbackID string) error

func (*MongoDatabase) RemoveStaleCallbacks

func (db *MongoDatabase) RemoveStaleCallbacks(timeout int64) error

func (*MongoDatabase) SetChannelConfig

func (db *MongoDatabase) SetChannelConfig(channelConfig *ChannelConfig) error

func (*MongoDatabase) SetChannelProject

func (db *MongoDatabase) SetChannelProject(channelID string, project string) error

func (*MongoDatabase) StoreCallback

func (db *MongoDatabase) StoreCallback(callbackID string, command *SlashCommand) error

type MongoSession

type MongoSession struct {
	*mgo.Session
}

MongoSession is currently a Mongo session.

func (MongoSession) Copy

func (s MongoSession) Copy() Session

Copy mocks mgo.Session.Copy()

func (MongoSession) DB

func (s MongoSession) DB(name string) DataLayer

DB shadows *mgo.DB to returns a DataLayer interface instead of *mgo.Database.

type Session

type Session interface {
	DB(name string) DataLayer
	SetSafe(safe *mgo.Safe)
	SetSyncTimeout(d time.Duration)
	SetSocketTimeout(d time.Duration)
	Close()
	Copy() Session
}

Session is an interface to access to the Session struct.

func NewSession

func NewSession(hosts string) Session

NewSession returns a new Mongo Session.

type SlashCommand

type SlashCommand struct {
	Token          string `schema:"token"`
	TeamID         string `schema:"team_id" bson:"team_id"`
	TeamDomain     string `schema:"team_domain" bson:"team_domain"`
	EnterpriseID   string `schema:"enterprise_id" bson:"enterprise_id"`
	EnterpriseName string `schema:"enterprise_name" bson:"enterprise_name"`
	ChannelID      string `schema:"channel_id" bson:"channel_id"`
	ChannelName    string `schema:"channel_name" bson:"channel_name"`
	UserID         string `schema:"user_id" bson:"user_id"`
	UserName       string `schema:"user_name" bson:"user_name"`
	Command        string `schema:"command"`
	Text           string `schema:"text"`
	ResponseURL    string `schema:"response_url" bson:"response_url"`
	TriggerID      string `schema:"trigger_id" bson:"trigger_id"`
	Timestamp      int64  `schema:"timestamp"`

	Config *ChannelConfig `bson:"-"`
}

Jump to

Keyboard shortcuts

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