Versions in this module Expand all Collapse all v1 v1.1.2 Dec 18, 2017 Changes in this version + const ConfigAPIKey + const ConfigBaseURL + const ConfigCallbackDomain + const ConfigContentType + const ConfigMaxLength + const ConfigPassword + const ConfigSendAuthorization + const ConfigSendBody + const ConfigSendMethod + const ConfigSendURL + const ConfigUsername + const NilStatusCode + var AnyChannelType = ChannelType("") + var NilChannelID = ChannelID + func GetTextAndAttachments(m Msg) string + func LogChannelEventReceived(r *http.Request, event ChannelEvent) + func LogMsgReceived(r *http.Request, msg Msg) + func LogMsgStatusReceived(r *http.Request, status MsgStatus) + func LogRequestIgnored(r *http.Request, details string) + func SplitAttachment(attachment string) (string, string) + func WriteChannelEventSuccess(ctx context.Context, w http.ResponseWriter, r *http.Request, ...) error + func WriteMsgSuccess(ctx context.Context, w http.ResponseWriter, r *http.Request, msgs []Msg) error type Backend + Cleanup func() error + MarkOutgoingMsgComplete func(context.Context, Msg, MsgStatus) + NewChannelEvent func(Channel, ChannelEventType, urns.URN) ChannelEvent + NewIncomingMsg func(channel Channel, urn urns.URN, text string) Msg + NewMsgStatusForExternalID func(Channel, string, MsgStatusValue) MsgStatus + NewMsgStatusForID func(Channel, MsgID, MsgStatusValue) MsgStatus + PopNextOutgoingMsg func(context.Context) (Msg, error) + Status func() string + StopMsgContact func(context.Context, Msg) + WasMsgSent func(context.Context, Msg) (bool, error) + WriteChannelEvent func(context.Context, ChannelEvent) error + WriteChannelLogs func(context.Context, []*ChannelLog) error type Channel + CallbackDomain func(fallbackDomain string) string + Name func() string + OrgConfigForKey func(key string, defaultValue interface{}) interface{} + Schemes func() []string + StringConfigForKey func(key string, defaultValue string) string + type ChannelEvent interface + AddLog func(log *ChannelLog) + ChannelUUID func() ChannelUUID + CreatedOn func() time.Time + EventID func() int64 + EventType func() ChannelEventType + Logs func() []*ChannelLog + OccurredOn func() time.Time + URN func() urns.URN + WithContactName func(name string) ChannelEvent + WithExtra func(extra map[string]interface{}) ChannelEvent + WithOccurredOn func(time.Time) ChannelEvent + type ChannelEventType string + const NewConversation + const Referral + type ChannelHandleFunc func(context.Context, Channel, http.ResponseWriter, *http.Request) ([]Event, error) type ChannelHandler + SendMsg func(context.Context, Msg) (MsgStatus, error) + type ChannelID struct + func NewChannelID(id int64) ChannelID + type ChannelLog struct + Channel Channel + CreatedOn time.Time + Description string + Elapsed time.Duration + Error string + Method string + MsgID MsgID + Request string + Response string + StatusCode int + URL string + func NewChannelLog(description string, channel Channel, msgID MsgID, method string, url string, ...) *ChannelLog + func NewChannelLogFromRR(description string, channel Channel, msgID MsgID, rr *utils.RequestResponse) *ChannelLog + func (l *ChannelLog) String() string + func (l *ChannelLog) WithError(description string, err error) *ChannelLog type ChannelType + func (ct ChannelType) String() string + type Event interface + EventID func() int64 + type Foreman struct + func NewForeman(server Server, maxSenders int) *Foreman + func (f *Foreman) Assign() + func (f *Foreman) Start() + func (f *Foreman) Stop() type MockBackend + func (mb *MockBackend) Cleanup() error + func (mb *MockBackend) GetLastChannelEvent() (ChannelEvent, error) + func (mb *MockBackend) GetLastContactName() string + func (mb *MockBackend) GetLastMsgStatus() (MsgStatus, error) + func (mb *MockBackend) GetLastStoppedMsgContact() Msg + func (mb *MockBackend) MarkOutgoingMsgComplete(ctx context.Context, msg Msg, s MsgStatus) + func (mb *MockBackend) NewChannelEvent(channel Channel, eventType ChannelEventType, urn urns.URN) ChannelEvent + func (mb *MockBackend) NewIncomingMsg(channel Channel, urn urns.URN, text string) Msg + func (mb *MockBackend) NewMsgStatusForExternalID(channel Channel, externalID string, status MsgStatusValue) MsgStatus + func (mb *MockBackend) NewMsgStatusForID(channel Channel, id MsgID, status MsgStatusValue) MsgStatus + func (mb *MockBackend) NewOutgoingMsg(channel Channel, id MsgID, urn urns.URN, text string, highPriority bool, ...) Msg + func (mb *MockBackend) PopNextOutgoingMsg(ctx context.Context) (Msg, error) + func (mb *MockBackend) PushOutgoingMsg(msg Msg) + func (mb *MockBackend) Status() string + func (mb *MockBackend) StopMsgContact(ctx context.Context, msg Msg) + func (mb *MockBackend) WasMsgSent(ctx context.Context, msg Msg) (bool, error) + func (mb *MockBackend) WriteChannelEvent(ctx context.Context, event ChannelEvent) error + func (mb *MockBackend) WriteChannelLogs(ctx context.Context, logs []*ChannelLog) error + type MockChannel struct + func (c *MockChannel) Address() string + func (c *MockChannel) CallbackDomain(fallbackDomain string) string + func (c *MockChannel) ChannelType() ChannelType + func (c *MockChannel) ConfigForKey(key string, defaultValue interface{}) interface{} + func (c *MockChannel) Country() string + func (c *MockChannel) Name() string + func (c *MockChannel) OrgConfigForKey(key string, defaultValue interface{}) interface{} + func (c *MockChannel) Schemes() []string + func (c *MockChannel) SetConfig(key string, value interface{}) + func (c *MockChannel) StringConfigForKey(key string, defaultValue string) string + func (c *MockChannel) UUID() ChannelUUID type Msg + EventID func() int64 + HighPriority func() bool + QuickReplies func() []string + SentOn func() *time.Time + WithAttachment func(url string) Msg + WithID func(id MsgID) Msg + WithUUID func(uuid MsgUUID) Msg type MsgStatus + AddLog func(log *ChannelLog) + ChannelUUID func() ChannelUUID + EventID func() int64 + ExternalID func() string + ID func() MsgID + Logs func() []*ChannelLog + SetExternalID func(string) + SetStatus func(MsgStatusValue) + Status func() MsgStatusValue + type MsgStatusValue string + const MsgErrored + const MsgWired type MsgUUID + func NewMsgUUIDFromString(uuidString string) MsgUUID + type Sender struct + func NewSender(foreman *Foreman, id int) *Sender + func (w *Sender) Start() + func (w *Sender) Stop() type Server + func NewServerWithLogger(config *config.Courier, backend Backend, logger *logrus.Logger) Server + AddHandlerRoute func(handler ChannelHandler, method string, action string, ...) error + Backend func() Backend + SendMsg func(context.Context, Msg) (MsgStatus, error) v0 v0.1.3 May 18, 2017 v0.1.2 May 18, 2017 v0.1.1 May 18, 2017 v0.1.0 May 18, 2017 Changes in this version + const ConfigAuthToken + const FacebookScheme + const TelScheme + const TelegramScheme + const TwitterScheme + var ErrChannelExpired = errors.New("channel expired") + var ErrChannelNotFound = errors.New("channel not found") + var ErrChannelWrongType = errors.New("channel type wrong") + var ErrMsgNotFound = errors.New("message not found") + var NilChannelUUID = ChannelUUID + var NilMsgID = MsgID + var NilMsgUUID = MsgUUID + var NilURN = URN("") + func EnsureSpoolDirPresent(spoolDir string, subdir string) (err error) + func RegisterBackend(backendType string, constructorFunc BackendConstructorFunc) + func RegisterFlusher(directory string, flusherFunc FlusherFunc) + func RegisterHandler(handler ChannelHandler) + func WriteError(w http.ResponseWriter, err error) error + func WriteIgnored(w http.ResponseWriter, message string) error + func WriteReceiveSuccess(w http.ResponseWriter, msg *Msg) error + func WriteStatusSuccess(w http.ResponseWriter, status *MsgStatusUpdate) error + func WriteToSpool(spoolDir string, subdir string, contents interface{}) error + type Backend interface + GetChannel func(ChannelType, ChannelUUID) (Channel, error) + Health func() string + Start func() error + Stop func() error + WriteMsg func(*Msg) error + WriteMsgStatus func(*MsgStatusUpdate) error + func NewBackend(config *config.Courier) (Backend, error) + type BackendConstructorFunc func(*config.Courier) Backend + type Channel interface + Address func() string + ChannelType func() ChannelType + ConfigForKey func(key string, defaultValue interface{}) interface{} + Country func() string + UUID func() ChannelUUID + func NewMockChannel(uuid string, channelType string, address string, country string, ...) Channel + type ChannelActionHandlerFunc func(Channel, http.ResponseWriter, *http.Request) error + type ChannelHandler interface + ChannelName func() string + ChannelType func() ChannelType + Initialize func(Server) error + type ChannelType string + type ChannelUUID struct + func NewChannelUUID(u string) (ChannelUUID, error) + type FlusherFunc func(filename string, contents []byte) error + type MockBackend struct + func NewMockBackend() *MockBackend + func (mb *MockBackend) AddChannel(channel Channel) + func (mb *MockBackend) ClearChannels() + func (mb *MockBackend) ClearQueueMsgs() + func (mb *MockBackend) GetChannel(cType ChannelType, uuid ChannelUUID) (Channel, error) + func (mb *MockBackend) GetLastQueueMsg() (*Msg, error) + func (mb *MockBackend) Health() string + func (mb *MockBackend) SetErrorOnQueue(shouldError bool) + func (mb *MockBackend) Start() error + func (mb *MockBackend) Stop() error + func (mb *MockBackend) WriteMsg(m *Msg) error + func (mb *MockBackend) WriteMsgStatus(status *MsgStatusUpdate) error + type Msg struct + Attachments []string + Channel Channel + ContactName string + ExternalID string + ID MsgID + ReceivedOn time.Time + Text string + URN URN + UUID MsgUUID + func NewIncomingMsg(channel Channel, urn URN, text string) *Msg + func (m *Msg) AddAttachment(url string) *Msg + func (m *Msg) WithContactName(name string) *Msg + func (m *Msg) WithExternalID(id string) *Msg + func (m *Msg) WithReceivedOn(date time.Time) *Msg + type MsgID struct + func NewMsgID(id int64) MsgID + func (i *MsgID) String() string + func (i *MsgID) UnmarshalJSON(bytes []byte) (err error) + func (i *MsgID) UnmarshalText(text []byte) (err error) + type MsgStatus string + const MsgDelivered + const MsgFailed + const MsgPending + const MsgQueued + const MsgSent + const NilMsgStatus + type MsgStatusUpdate struct + Channel Channel + CreatedOn time.Time + ExternalID string + ID MsgID + Status MsgStatus + func NewStatusUpdateForExternalID(channel Channel, externalID string, status MsgStatus) *MsgStatusUpdate + func NewStatusUpdateForID(channel Channel, id MsgID, status MsgStatus) *MsgStatusUpdate + func (m *MsgStatusUpdate) Release() + type MsgUUID struct + func NewMsgUUID() MsgUUID + type Server interface + AddChannelRoute func(handler ChannelHandler, method string, action string, ...) *mux.Route + Config func() *config.Courier + GetChannel func(ChannelType, ChannelUUID) (Channel, error) + Router func() *mux.Router + Start func() error + Stop func() error + StopChan func() chan bool + Stopped func() bool + WaitGroup func() *sync.WaitGroup + WriteMsg func(*Msg) error + WriteMsgStatus func(*MsgStatusUpdate) error + func NewServer(config *config.Courier, backend Backend) Server + type URN string + func NewTelURNForChannel(number string, channel Channel) URN + func NewTelURNForCountry(number string, country string) URN + func NewTelegramURN(identifier int64) URN + func NewURNFromParts(scheme string, path string) (URN, error)