Documentation ¶
Overview ¶
Package stewdy is a generated protocol buffer package.
It is generated from these files:
stewdy.proto
It has these top-level messages:
Campaign Schedule Target
Index ¶
- Variables
- func AddTargets(campaignID string, targets []*Target) error
- func Answered(targetID, uniqueID string) error
- func Connected(uniqueID, operatorID string) error
- func Failed(targetID string) error
- func Hanguped(uniqueID string) error
- func Init(fileName string)
- func Len(campaignID string) (int, error)
- func NextAttemptTime(campaignID string) (time.Time, error)
- func On(e TargetEvent, f EventHandler)
- func RemoveTarget(campaignID, targetID string)
- func SetQueueStat(id string, free, queued int)
- func UpdateCampaign(c Campaign) error
- type Campaign
- func (*Campaign) Descriptor() ([]byte, []int)
- func (m *Campaign) GetBatchSize() int32
- func (m *Campaign) GetConcurrentCalls() int32
- func (m *Campaign) GetId() string
- func (m *Campaign) GetIntensity() int32
- func (m *Campaign) GetIsActive() bool
- func (m *Campaign) GetMaxAttempts() int32
- func (m *Campaign) GetMaxCallDuration() int32
- func (m *Campaign) GetMultiplier() int32
- func (m *Campaign) GetNextAttemptDelay() int64
- func (m *Campaign) GetQueueID() string
- func (m *Campaign) GetResetOnActivation() bool
- func (m *Campaign) GetResetOnNewSchedule() bool
- func (m *Campaign) GetTimeTable() []*Schedule
- func (m *Campaign) GetWaitForAnswer() int32
- func (m *Campaign) GetWaitForConnect() int32
- func (m *Campaign) Marshal() (dAtA []byte, err error)
- func (m *Campaign) MarshalTo(dAtA []byte) (int, error)
- func (*Campaign) ProtoMessage()
- func (m *Campaign) Reset()
- func (m *Campaign) Size() (n int)
- func (m *Campaign) String() string
- func (m *Campaign) Unmarshal(dAtA []byte) error
- type EventHandler
- type Schedule
- func (*Schedule) Descriptor() ([]byte, []int)
- func (m *Schedule) GetId() string
- func (m *Schedule) GetStart() int32
- func (m *Schedule) GetStop() int32
- func (m *Schedule) GetWeekday() int32
- func (m *Schedule) Marshal() (dAtA []byte, err error)
- func (m *Schedule) MarshalTo(dAtA []byte) (int, error)
- func (*Schedule) ProtoMessage()
- func (m *Schedule) Reset()
- func (m *Schedule) Size() (n int)
- func (m *Schedule) String() string
- func (m *Schedule) Unmarshal(dAtA []byte) error
- type Target
- func (*Target) Descriptor() ([]byte, []int)
- func (m *Target) GetAnswerTime() int64
- func (m *Target) GetAttempts() int32
- func (m *Target) GetCampaignID() string
- func (m *Target) GetClientId() string
- func (m *Target) GetConnectTime() int64
- func (m *Target) GetHangupTime() int64
- func (m *Target) GetId() string
- func (m *Target) GetLastAttemptTime() int64
- func (m *Target) GetNextAttemptTime() int64
- func (m *Target) GetOperatorID() string
- func (m *Target) GetPhoneNumber() string
- func (m *Target) GetPreferredOperatorID() string
- func (m *Target) GetUniqueId() string
- func (m *Target) Marshal() (dAtA []byte, err error)
- func (m *Target) MarshalTo(dAtA []byte) (int, error)
- func (*Target) ProtoMessage()
- func (m *Target) Reset()
- func (m *Target) Size() (n int)
- func (m *Target) String() string
- func (m *Target) Unmarshal(dAtA []byte) error
- type TargetEvent
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoQID = errors.New("no queue id provided") ErrEmptyTimeTable = errors.New("timetable is empty") )
Campaigns errors
var ( ErrNotFound = errors.New("not found") ErrNotProtoMessage = errors.New("item is not a proto.Message") ErrNoIdProvided = errors.New("no id provided") ErrShouldBeSlice = errors.New("data should be slice of inteface{}") )
DB Errors
var ( ErrInvalidLengthStewdy = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowStewdy = fmt.Errorf("proto: integer overflow") )
Functions ¶
func AddTargets ¶
AddTargets adds targets for campaign to campaign's targets list. Returns error if campaign is not found, or db error occured.
func Answered ¶
Answered marks target as answered and sets uniqueID field. Returns error when target does not found.
func Connected ¶
Connected marks target with provided uniqueID as connected with operator and sets operatorID field. Also emits EventSuccess event with found target. Returns error when target does not found.
func Failed ¶
Failed marks target as failed. If no attempts remained, will remove target from campaign's target list. Returns error when target does not found.
func Hanguped ¶
Hanguped marks target with uniqueID provided as hanguped. If Returns error when target does not found.
func Init ¶
func Init(fileName string)
Init open database with fileName provided. If file does not exists, creates it. If any error occured, will panic.
func Len ¶
Len returns targets count for campaign. It counts targets in target list, plus originating and answered targets. Connected targets are not included. Returns error if campaign does not found.
func NextAttemptTime ¶
NextAttemptTime returns time when next originate should be emitted. May be in past. Returns error if campaign does not found.
func RemoveTarget ¶
func RemoveTarget(campaignID, targetID string)
RemoveTarget removes target with targetID for campaignID. If no campaign found or no target found does nothing.
func SetQueueStat ¶
SetQueueStat updates internal statistic of call queue. Takes queue id, number of free operators and number of queued calls as arguments.
func UpdateCampaign ¶
UpdateCampaign updates campaign settings passed as argument. If campaign is now exists, will create it. Returns error if no queue id in campaign, if invalid timetable, or db error occured.
Types ¶
type Campaign ¶
type Campaign struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` QueueID string `protobuf:"bytes,2,opt,name=queueID,proto3" json:"queueID,omitempty"` IsActive bool `protobuf:"varint,3,opt,name=isActive,proto3" json:"isActive,omitempty"` ResetOnNewSchedule bool `protobuf:"varint,4,opt,name=resetOnNewSchedule,proto3" json:"resetOnNewSchedule,omitempty"` ResetOnActivation bool `protobuf:"varint,5,opt,name=resetOnActivation,proto3" json:"resetOnActivation,omitempty"` MaxAttempts int32 `protobuf:"varint,6,opt,name=maxAttempts,proto3" json:"maxAttempts,omitempty"` NextAttemptDelay int64 `protobuf:"varint,7,opt,name=nextAttemptDelay,proto3" json:"nextAttemptDelay,omitempty"` ConcurrentCalls int32 `protobuf:"varint,8,opt,name=concurrentCalls,proto3" json:"concurrentCalls,omitempty"` Multiplier int32 `protobuf:"varint,9,opt,name=multiplier,proto3" json:"multiplier,omitempty"` BatchSize int32 `protobuf:"varint,10,opt,name=batchSize,proto3" json:"batchSize,omitempty"` Intensity int32 `protobuf:"varint,11,opt,name=intensity,proto3" json:"intensity,omitempty"` WaitForAnswer int32 `protobuf:"varint,12,opt,name=waitForAnswer,proto3" json:"waitForAnswer,omitempty"` WaitForConnect int32 `protobuf:"varint,13,opt,name=waitForConnect,proto3" json:"waitForConnect,omitempty"` MaxCallDuration int32 `protobuf:"varint,14,opt,name=maxCallDuration,proto3" json:"maxCallDuration,omitempty"` TimeTable []*Schedule `protobuf:"bytes,15,rep,name=timeTable" json:"timeTable,omitempty"` }
func ActiveCampaigns ¶
func ActiveCampaigns() []Campaign
ActiveCampaigns returns slice of ids of campaigns which isActive = true and scheduled at this moment.
func GetCampaignByID ¶
GetCampaignByID returns campaign by id.
func (*Campaign) Descriptor ¶
func (*Campaign) GetBatchSize ¶
func (*Campaign) GetConcurrentCalls ¶
func (*Campaign) GetIntensity ¶
func (*Campaign) GetIsActive ¶
func (*Campaign) GetMaxAttempts ¶
func (*Campaign) GetMaxCallDuration ¶
func (*Campaign) GetMultiplier ¶
func (*Campaign) GetNextAttemptDelay ¶
func (*Campaign) GetQueueID ¶
func (*Campaign) GetResetOnActivation ¶
func (*Campaign) GetResetOnNewSchedule ¶
func (*Campaign) GetTimeTable ¶
func (*Campaign) GetWaitForAnswer ¶
func (*Campaign) GetWaitForConnect ¶
func (*Campaign) ProtoMessage ¶
func (*Campaign) ProtoMessage()
type EventHandler ¶
type EventHandler func(t Target)
EventHandler is a hook func to handle target's events.
type Schedule ¶
type Schedule struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Weekday int32 `protobuf:"varint,2,opt,name=weekday,proto3" json:"weekday,omitempty"` Start int32 `protobuf:"varint,3,opt,name=start,proto3" json:"start,omitempty"` Stop int32 `protobuf:"varint,4,opt,name=stop,proto3" json:"stop,omitempty"` }
func (*Schedule) Descriptor ¶
func (*Schedule) GetWeekday ¶
func (*Schedule) ProtoMessage ¶
func (*Schedule) ProtoMessage()
type Target ¶
type Target struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` CampaignID string `protobuf:"bytes,2,opt,name=campaignID,proto3" json:"campaignID,omitempty"` PhoneNumber string `protobuf:"bytes,3,opt,name=phoneNumber,proto3" json:"phoneNumber,omitempty"` ClientId string `protobuf:"bytes,4,opt,name=clientId,proto3" json:"clientId,omitempty"` PreferredOperatorID string `protobuf:"bytes,5,opt,name=preferredOperatorID,proto3" json:"preferredOperatorID,omitempty"` Attempts int32 `protobuf:"varint,6,opt,name=attempts,proto3" json:"attempts,omitempty"` LastAttemptTime int64 `protobuf:"varint,7,opt,name=lastAttemptTime,proto3" json:"lastAttemptTime,omitempty"` NextAttemptTime int64 `protobuf:"varint,8,opt,name=nextAttemptTime,proto3" json:"nextAttemptTime,omitempty"` UniqueId string `protobuf:"bytes,9,opt,name=uniqueId,proto3" json:"uniqueId,omitempty"` OperatorID string `protobuf:"bytes,10,opt,name=operatorID,proto3" json:"operatorID,omitempty"` AnswerTime int64 `protobuf:"varint,11,opt,name=answerTime,proto3" json:"answerTime,omitempty"` ConnectTime int64 `protobuf:"varint,12,opt,name=connectTime,proto3" json:"connectTime,omitempty"` HangupTime int64 `protobuf:"varint,13,opt,name=hangupTime,proto3" json:"hangupTime,omitempty"` }
func (*Target) Descriptor ¶
func (*Target) GetAnswerTime ¶
func (*Target) GetAttempts ¶
func (*Target) GetCampaignID ¶
func (*Target) GetClientId ¶
func (*Target) GetConnectTime ¶
func (*Target) GetHangupTime ¶
func (*Target) GetLastAttemptTime ¶
func (*Target) GetNextAttemptTime ¶
func (*Target) GetOperatorID ¶
func (*Target) GetPhoneNumber ¶
func (*Target) GetPreferredOperatorID ¶
func (*Target) GetUniqueId ¶
func (*Target) ProtoMessage ¶
func (*Target) ProtoMessage()
type TargetEvent ¶
type TargetEvent int
TargetEvent is a type for target's events types.
const ( EventOriginate TargetEvent = iota + 1 EventAnswer EventConnect EventFail EventSuccess EventHangup EventRemove )
Events constants
func (TargetEvent) String ¶
func (i TargetEvent) String() string