stewdy

package module
v0.0.0-...-414797b Latest Latest
Warning

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

Go to latest
Published: May 21, 2018 License: MIT Imports: 13 Imported by: 0

README

stewdy

Stewdy Build Status GoDoc License

Stupid dialer library written on Go

This is an attempt to create library for making dialers with any call targets sources and any PBX.

Project at a very early stage.

Generating code

Install the standard protocol buffer implementation from https://github.com/google/protobuf.

Install Protocol Buffers for Go with Gadgets:

go get github.com/gogo/protobuf/protoc-gen-gofast

Generate structs from .proto:

protoc --gofast_out=. *.proto

Generate stringer

go generate

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

Constants

This section is empty.

Variables

View Source
var (
	ErrNoQID          = errors.New("no queue id provided")
	ErrEmptyTimeTable = errors.New("timetable is empty")
)

Campaigns errors

View Source
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

View Source
var (
	ErrInvalidLengthStewdy = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowStewdy   = fmt.Errorf("proto: integer overflow")
)

Functions

func AddTargets

func AddTargets(campaignID string, targets []*Target) error

AddTargets adds targets for campaign to campaign's targets list. Returns error if campaign is not found, or db error occured.

func Answered

func Answered(targetID, uniqueID string) error

Answered marks target as answered and sets uniqueID field. Returns error when target does not found.

func Connected

func Connected(uniqueID, operatorID string) error

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

func Failed(targetID string) error

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

func Hanguped(uniqueID string) error

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

func Len(campaignID string) (int, error)

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

func NextAttemptTime(campaignID string) (time.Time, error)

NextAttemptTime returns time when next originate should be emitted. May be in past. Returns error if campaign does not found.

func On

func On(e TargetEvent, f EventHandler)

On registers event handler for provided e.

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

func SetQueueStat(id string, free, queued int)

SetQueueStat updates internal statistic of call queue. Takes queue id, number of free operators and number of queued calls as arguments.

func UpdateCampaign

func UpdateCampaign(c Campaign) error

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

func GetCampaignByID(id string) (Campaign, error)

GetCampaignByID returns campaign by id.

func (*Campaign) Descriptor

func (*Campaign) Descriptor() ([]byte, []int)

func (*Campaign) GetBatchSize

func (m *Campaign) GetBatchSize() int32

func (*Campaign) GetConcurrentCalls

func (m *Campaign) GetConcurrentCalls() int32

func (*Campaign) GetId

func (m *Campaign) GetId() string

func (*Campaign) GetIntensity

func (m *Campaign) GetIntensity() int32

func (*Campaign) GetIsActive

func (m *Campaign) GetIsActive() bool

func (*Campaign) GetMaxAttempts

func (m *Campaign) GetMaxAttempts() int32

func (*Campaign) GetMaxCallDuration

func (m *Campaign) GetMaxCallDuration() int32

func (*Campaign) GetMultiplier

func (m *Campaign) GetMultiplier() int32

func (*Campaign) GetNextAttemptDelay

func (m *Campaign) GetNextAttemptDelay() int64

func (*Campaign) GetQueueID

func (m *Campaign) GetQueueID() string

func (*Campaign) GetResetOnActivation

func (m *Campaign) GetResetOnActivation() bool

func (*Campaign) GetResetOnNewSchedule

func (m *Campaign) GetResetOnNewSchedule() bool

func (*Campaign) GetTimeTable

func (m *Campaign) GetTimeTable() []*Schedule

func (*Campaign) GetWaitForAnswer

func (m *Campaign) GetWaitForAnswer() int32

func (*Campaign) GetWaitForConnect

func (m *Campaign) GetWaitForConnect() int32

func (*Campaign) Marshal

func (m *Campaign) Marshal() (dAtA []byte, err error)

func (*Campaign) MarshalTo

func (m *Campaign) MarshalTo(dAtA []byte) (int, error)

func (*Campaign) ProtoMessage

func (*Campaign) ProtoMessage()

func (*Campaign) Reset

func (m *Campaign) Reset()

func (*Campaign) Size

func (m *Campaign) Size() (n int)

func (*Campaign) String

func (m *Campaign) String() string

func (*Campaign) Unmarshal

func (m *Campaign) Unmarshal(dAtA []byte) error

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) Descriptor() ([]byte, []int)

func (*Schedule) GetId

func (m *Schedule) GetId() string

func (*Schedule) GetStart

func (m *Schedule) GetStart() int32

func (*Schedule) GetStop

func (m *Schedule) GetStop() int32

func (*Schedule) GetWeekday

func (m *Schedule) GetWeekday() int32

func (*Schedule) Marshal

func (m *Schedule) Marshal() (dAtA []byte, err error)

func (*Schedule) MarshalTo

func (m *Schedule) MarshalTo(dAtA []byte) (int, error)

func (*Schedule) ProtoMessage

func (*Schedule) ProtoMessage()

func (*Schedule) Reset

func (m *Schedule) Reset()

func (*Schedule) Size

func (m *Schedule) Size() (n int)

func (*Schedule) String

func (m *Schedule) String() string

func (*Schedule) Unmarshal

func (m *Schedule) Unmarshal(dAtA []byte) error

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) Descriptor() ([]byte, []int)

func (*Target) GetAnswerTime

func (m *Target) GetAnswerTime() int64

func (*Target) GetAttempts

func (m *Target) GetAttempts() int32

func (*Target) GetCampaignID

func (m *Target) GetCampaignID() string

func (*Target) GetClientId

func (m *Target) GetClientId() string

func (*Target) GetConnectTime

func (m *Target) GetConnectTime() int64

func (*Target) GetHangupTime

func (m *Target) GetHangupTime() int64

func (*Target) GetId

func (m *Target) GetId() string

func (*Target) GetLastAttemptTime

func (m *Target) GetLastAttemptTime() int64

func (*Target) GetNextAttemptTime

func (m *Target) GetNextAttemptTime() int64

func (*Target) GetOperatorID

func (m *Target) GetOperatorID() string

func (*Target) GetPhoneNumber

func (m *Target) GetPhoneNumber() string

func (*Target) GetPreferredOperatorID

func (m *Target) GetPreferredOperatorID() string

func (*Target) GetUniqueId

func (m *Target) GetUniqueId() string

func (*Target) Marshal

func (m *Target) Marshal() (dAtA []byte, err error)

func (*Target) MarshalTo

func (m *Target) MarshalTo(dAtA []byte) (int, error)

func (*Target) ProtoMessage

func (*Target) ProtoMessage()

func (*Target) Reset

func (m *Target) Reset()

func (*Target) Size

func (m *Target) Size() (n int)

func (*Target) String

func (m *Target) String() string

func (*Target) Unmarshal

func (m *Target) Unmarshal(dAtA []byte) error

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

Jump to

Keyboard shortcuts

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