Documentation ¶
Index ¶
Constants ¶
const (
DefaultUpdateInterval = time.Minute
)
Variables ¶
var ( MessageNotFound = errors.New("Message not found") MessageSuspended = errors.New("Message suspended") )
Functions ¶
func UseLogger ¶
func UseLogger(newLogger log.LoggerInterface)
UseLogger uses a specified seelogger.LoggerInterface to output library logger. Use this func if you are using Seelog logging system in your app.
Types ¶
type MessageStatusMgoStorage ¶
type MessageStatusMgoStorage struct {
// contains filtered or unexported fields
}
MessageStatusMgoStorage is a default mgo implementation of the MessageStatusStorageInterface.
func NewMessageStatusMgoStorage ¶
func NewMessageStatusMgoStorage(dbHelper *mgohelper.DbHelper) (*MessageStatusMgoStorage, error)
func (*MessageStatusMgoStorage) Get ¶
func (ms *MessageStatusMgoStorage) Get(messageId int64) (*MessageStatus, error)
func (*MessageStatusMgoStorage) GetPending ¶
func (ms *MessageStatusMgoStorage) GetPending() ([]MessageStatus, error)
func (*MessageStatusMgoStorage) Put ¶
func (ms *MessageStatusMgoStorage) Put(message *MessageStatus) error
type MessageTracker ¶
type MessageTracker struct {
// contains filtered or unexported fields
}
MessageTracker represents a running goroutine that polls SMSC service to track status of sent messages which status is pending. This object is created when a goroutine is started by StartTracking and can be used to stop the goroutine using Close func. After goroutine is stopped by Close() this object cannot be used anymore.
func StartTracking ¶
func StartTracking(storage StatusContainer, statusFetcher StatusFetcher, updateInterval time.Duration) (tracker *MessageTracker, e error)
StartTracking creates a new tracker for the specified storage and starts the tracking process in a separate goroutine. Uses 'statusFetcher' argument to call the SMSC service when updates for pending messages are needed. To stop it, call Close on the returned tracker instance.
func (*MessageTracker) IsStopped ¶
func (t *MessageTracker) IsStopped() bool
IsStopped returns true if the tracker goroutine was stopped by the Stop func and the tracker is unusable anymore.
func (*MessageTracker) Stop ¶
func (t *MessageTracker) Stop() error
Stop stops the polling goroutine and closes the tracker object. A stopped tracker cannot be used anymore.
NOTE 1: Goroutine doesn't terminate immediately (it can be processing pending issues), but Stop func is non blocking itself.
type SenderCheckerImpl ¶
type SenderCheckerImpl struct {
// contains filtered or unexported fields
}
HttpSenderChecker provides the functionality to send sms and track its status.
It consists of a sender, status getter, message storage, and a tracker goroutine. When sms is sent using 'Send', SenderChecker implementation adds a 'pending' entry to the storage. Then the tracker goroutine starts polling the smsc gateway using the status getter. It polls it until message is delivered and updates the message status in the storage each time.
It can be also used without tracking functionality. See 'track' flag in the Send func.
func NewSenderCheckerImpl ¶
func NewSenderCheckerImpl(opts *SmscClientOptions, storage StatusContainer, updateInterval time.Duration) (*SenderCheckerImpl, error)
func (*SenderCheckerImpl) GetActualStatus ¶
func (c *SenderCheckerImpl) GetActualStatus(id int64) (*MessageStatus, error)
type SenderFetcherImpl ¶
type SenderFetcherImpl struct {
// contains filtered or unexported fields
}
SenderFetcherImpl is a plain implementation of Sender and StatusFetcher interfaces that interacts with SMSC web gateway. Unlike SenderCheckerImpl, SenderFetcherImpl doesn't track or store anything, it is just a gateway caller without any side-effects.
func NewSenderFetcherImpl ¶
func NewSenderFetcherImpl(opts *SmscClientOptions) (*SenderFetcherImpl, error)
func (*SenderFetcherImpl) FetchStatus ¶
func (c *SenderFetcherImpl) FetchStatus(id int64, phone string) (*CheckStatusResponse, error)
type SmscClientOptions ¶
SmscClientOptions encapsulates configuration used to send sms messages using smsc.ru