models

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OffsetMinute means our offset is in minutes
	OffsetMinute = OffsetUnit("M")

	// OffsetHour means our offset is in hours
	OffsetHour = OffsetUnit("H")

	// OffsetDay means our offset is in days
	OffsetDay = OffsetUnit("D")

	// OffsetWeek means our offset is in weeks
	OffsetWeek = OffsetUnit("W")

	// NilDeliveryHour is our constant for not having a set delivery hour
	NilDeliveryHour = -1
)
View Source
const (
	DirectionIn  = MsgDirection("I")
	DirectionOut = MsgDirection("O")
)
View Source
const (
	VisibilityVisible  = MsgVisibility("V")
	VisibilityArchived = MsgVisibility("A")
	VisibilityDeleted  = MsgVisibility("D")
)
View Source
const (
	TypeInbox = MsgType("I")
	TypeFlow  = MsgType("F")
	TypeIVR   = MsgType("V")
	TypeUSSD  = MsgType("U")
)
View Source
const (
	MsgStatusInitializing = MsgStatus("I")
	MsgStatusPending      = MsgStatus("P")
	MsgStatusQueued       = MsgStatus("Q")
	MsgStatusWired        = MsgStatus("W")
	MsgStatusSent         = MsgStatus("S")
	MsgStatusHandled      = MsgStatus("H")
	MsgStatusErrored      = MsgStatus("E")
	MsgStatusFailed       = MsgStatus("F")
	MsgStatusResent       = MsgStatus("R")
)
View Source
const (
	SessionStatusActive    = "A"
	SessionStatusCompleted = "C"
	SessionStatusErrored   = "E"
	SessionStatusWaiting   = "W"
)
View Source
const ChannelTypeAndroid = ChannelType("A")
View Source
const InsertMsgSQL = `` /* 565-byte string literal not displayed */

Variables

View Source
var (
	ExitInterrupted = null.NewString("I", true)
	ExitCompleted   = null.NewString("C", true)
	ExitExpired     = null.NewString("E", true)
)
View Source
var NilTopupID = TopupID(null.NewInt(0, false))

NilTopupID is our nil value for topup id

Functions

func ApplyEvent

func ApplyEvent(ctx context.Context, tx *sqlx.Tx, rp *redis.Pool, session *Session, e flows.Event) error

ApplyEvent applies the passed in event, IE, creates the db objects required etc..

func ApplyPostEventHooks added in v0.0.17

func ApplyPostEventHooks(ctx context.Context, tx *sqlx.Tx, rp *redis.Pool, org *OrgAssets, sessions []*Session) error

ApplyPostEventHooks runs through all the post event hooks for the passed in sessions and applies their events

func ApplyPreEventHooks added in v0.0.17

func ApplyPreEventHooks(ctx context.Context, tx *sqlx.Tx, rp *redis.Pool, org *OrgAssets, sessions []*Session) error

ApplyPreEventHooks runs through all the pre event hooks for the passed in sessions and applies their events

func AssertContactMessagesPresent added in v0.0.11

func AssertContactMessagesPresent(t *testing.T, db *sqlx.DB, contactIDs []flows.ContactID, extraWhere string)

func AssertContactRunsPresent added in v0.0.11

func AssertContactRunsPresent(t *testing.T, db *sqlx.DB, contactIDs []flows.ContactID, flowID FlowID, extraWhere string)

func AssertContactSessionsPresent added in v0.0.11

func AssertContactSessionsPresent(t *testing.T, db *sqlx.DB, contactIDs []flows.ContactID, extraWhere string)

func BulkSQL added in v0.0.22

func BulkSQL(ctx context.Context, label string, tx *sqlx.Tx, sql string, vs []interface{}) error

func LoadContacts added in v0.0.5

func LoadContacts(ctx context.Context, db *sqlx.DB, session flows.SessionAssets, org *OrgAssets, ids []flows.ContactID) ([]*flows.Contact, error)

LoadContacts loads a set of contacts for the passed in ids

func MarkEventsFired added in v0.0.19

func MarkEventsFired(ctx context.Context, tx *sqlx.Tx, fires []*EventFire, fired time.Time) error

MarkEventsFired sets the fired date on all the passed in event fires and updates the associated rows in the database

func MarkMessagesPending added in v0.0.5

func MarkMessagesPending(ctx context.Context, tx *sqlx.Tx, msgs []*Msg) error

MarkMessagesPending marks the passed in messages as pending

func MarkMessagesQueued added in v0.0.2

func MarkMessagesQueued(ctx context.Context, tx *sqlx.Tx, msgs []*Msg) error

MarkMessagesQueued marks the passed in messages as queued

func RegisterEventHandler added in v0.0.17

func RegisterEventHandler(eventType string, handler EventHandler)

RegisterEventHandler registers the passed in handler as being interested in the passed in type

Types

type Campaign added in v0.0.17

type Campaign struct {
	// contains filtered or unexported fields
}

Campaign is our struct for a campaign and all its events

func (*Campaign) Events added in v0.0.17

func (c *Campaign) Events() []*CampaignEvent

Events returns the list of events for this campaign

func (*Campaign) GroupID added in v0.0.17

func (c *Campaign) GroupID() GroupID

GroupID returns the id of the group this campaign works against

func (*Campaign) GroupUUID added in v0.0.17

func (c *Campaign) GroupUUID() assets.GroupUUID

GroupUUID returns the uuid of the group this campaign works against

func (*Campaign) ID added in v0.0.17

func (c *Campaign) ID() CampaignID

ID return the database id of this campaign

func (*Campaign) Name added in v0.0.17

func (c *Campaign) Name() string

Name returns the name of this campaign

func (*Campaign) UUID added in v0.0.17

func (c *Campaign) UUID() CampaignUUID

UUID returns the UUID of this campaign

type CampaignEvent added in v0.0.17

type CampaignEvent struct {
	// contains filtered or unexported fields
}

CampaignEvent is our struct for an individual campaign event

func (*CampaignEvent) Campaign added in v0.0.17

func (e *CampaignEvent) Campaign() *Campaign

Campaign returns the campaign this event is part of

func (*CampaignEvent) DeliveryHour added in v0.0.17

func (e *CampaignEvent) DeliveryHour() int

DeliveryHour returns the hour this event should send at, if any

func (*CampaignEvent) ID added in v0.0.17

ID returns the database id for this campaign event

func (*CampaignEvent) Offset added in v0.0.17

func (e *CampaignEvent) Offset() int

Offset returns the offset for thi campaign event

func (*CampaignEvent) RelativeToID added in v0.0.17

func (e *CampaignEvent) RelativeToID() FieldID

RelativeToID returns the ID of the field this event is relative to

func (*CampaignEvent) RelativeToKey added in v0.0.17

func (e *CampaignEvent) RelativeToKey() string

RelativeToKey returns the key of the field this event is relative to

func (*CampaignEvent) ScheduleForTime added in v0.0.17

func (e *CampaignEvent) ScheduleForTime(tz *time.Location, now time.Time, start time.Time) (*time.Time, error)

ScheduleForTime calculates the next fire (if any) for the passed in contact for this CampaignEvent

func (*CampaignEvent) UUID added in v0.0.17

func (e *CampaignEvent) UUID() CampaignEventUUID

UUID returns the UUID of this campaign event

func (*CampaignEvent) Unit added in v0.0.17

func (e *CampaignEvent) Unit() OffsetUnit

Unit returns the unit for this campaign event

func (*CampaignEvent) UnmarshalJSON added in v0.0.17

func (e *CampaignEvent) UnmarshalJSON(data []byte) error

UnmarshalJSON is our unmarshaller for json data

type CampaignEventID added in v0.0.17

type CampaignEventID int

CampaignEventID is our type for campaign event ids

type CampaignEventUUID added in v0.0.17

type CampaignEventUUID utils.UUID

CampaignEventUUID is our type for campaign event UUIDs

type CampaignID added in v0.0.17

type CampaignID int

CampaignID is our type for campaign ids

type CampaignUUID added in v0.0.17

type CampaignUUID utils.UUID

CampaignUUID is our type for campaign UUIDs

type Channel added in v0.0.5

type Channel struct {
	// contains filtered or unexported fields
}

Channel is the mailroom struct that represents channels

func (*Channel) Address added in v0.0.5

func (c *Channel) Address() string

Address returns the name of this channel

func (*Channel) Country added in v0.0.5

func (c *Channel) Country() string

Country returns the contry code for this channel

func (*Channel) ID added in v0.0.5

func (c *Channel) ID() ChannelID

ID returns the id of this channel

func (*Channel) MatchPrefixes added in v0.0.5

func (c *Channel) MatchPrefixes() []string

MatchPrefixes returns the prefixes we should also match when determining channel affinity

func (*Channel) Name added in v0.0.5

func (c *Channel) Name() string

Name returns the name of this channel

func (*Channel) Parent added in v0.0.5

func (c *Channel) Parent() *assets.ChannelReference

Parent returns the UUID of the parent channel to this channel

func (*Channel) Roles added in v0.0.5

func (c *Channel) Roles() []assets.ChannelRole

Roles returns the roles this channel supports

func (*Channel) Schemes added in v0.0.5

func (c *Channel) Schemes() []string

Schemes returns the schemes this channel supports

func (*Channel) TPS added in v0.0.5

func (c *Channel) TPS() int

TPS returns the max number of transactions per second this channel supports

func (*Channel) Type added in v0.0.5

func (c *Channel) Type() ChannelType

Type returns the channel type for this channel

func (*Channel) UUID added in v0.0.5

func (c *Channel) UUID() assets.ChannelUUID

UUID returns the UUID of this channel

type ChannelID

type ChannelID int

type ChannelType added in v0.0.5

type ChannelType string

type ConnectionID

type ConnectionID null.Int

type ContactID

type ContactID int64

type ContactURNID

type ContactURNID int

type EventCommitHook added in v0.0.19

type EventCommitHook interface {
	Apply(context.Context, *sqlx.Tx, *redis.Pool, *OrgAssets, map[*Session][]interface{}) error
}

EventCommitHook defines a callback that will accept a certain type of events across session, either before or after committing

type EventFire added in v0.0.19

type EventFire struct {
	FireID    FireID          `db:"fire_id"`
	EventID   CampaignEventID `db:"event_id"`
	ContactID flows.ContactID `db:"contact_id"`
	Scheduled time.Time       `db:"scheduled"`
	Fired     *time.Time      `db:"fired"`
}

EventFire represents a single campaign event fire for an event and contact

func LoadEventFires added in v0.0.19

func LoadEventFires(ctx context.Context, db *sqlx.DB, ids []int64) ([]*EventFire, error)

LoadEventFires loads all the event fires with the passed in ids

type EventHandler added in v0.0.17

type EventHandler func(context.Context, *sqlx.Tx, *redis.Pool, *Session, flows.Event) error

EventHandler defines a call for handling events that occur in a flow

type ExitType

type ExitType null.String

type Field added in v0.0.5

type Field struct {
	// contains filtered or unexported fields
}

Field is our mailroom type for contact field types

func (*Field) ID added in v0.0.17

func (f *Field) ID() FieldID

ID returns the ID of this field

func (*Field) Key added in v0.0.5

func (f *Field) Key() string

Key returns the key for this field

func (*Field) Name added in v0.0.5

func (f *Field) Name() string

Name returns the name for this field

func (*Field) Type added in v0.0.5

func (f *Field) Type() assets.FieldType

Type returns the value type for this field

func (*Field) UUID added in v0.0.5

func (f *Field) UUID() FieldUUID

UUID returns the UUID of this field

type FieldID added in v0.0.17

type FieldID int

FieldID is our type for the database field ID

type FieldUUID added in v0.0.5

type FieldUUID utils.UUID

type FieldValue added in v0.0.17

type FieldValue struct {
	Text     types.XText        `json:"text"`
	Datetime *types.XDateTime   `json:"datetime,omitempty"`
	Number   *types.XNumber     `json:"number,omitempty"`
	State    flows.LocationPath `json:"state,omitempty"`
	District flows.LocationPath `json:"district,omitempty"`
	Ward     flows.LocationPath `json:"ward,omitempty"`
}

FieldValue is our utility struct for the value of a field

type FireID added in v0.0.19

type FireID int

FireID is our id for our event fires

type Flow added in v0.0.5

type Flow struct {
	// contains filtered or unexported fields
}

Flow is the mailroom type for a flow

func (*Flow) Definition added in v0.0.5

func (f *Flow) Definition() json.RawMessage

Definition returns the definition for this flow

func (*Flow) ID added in v0.0.5

func (f *Flow) ID() FlowID

ID returns the ID for this flow

func (*Flow) Name added in v0.0.5

func (f *Flow) Name() string

Name returns the name of this flow

func (*Flow) UUID added in v0.0.5

func (f *Flow) UUID() assets.FlowUUID

UUID returns the UUID for this flow

type FlowID

type FlowID int

type FlowRun

type FlowRun struct {
	ID         FlowID        `db:"id"`
	UUID       flows.RunUUID `db:"uuid"`
	IsActive   bool          `db:"is_active"`
	CreatedOn  time.Time     `db:"created_on"`
	ModifiedOn time.Time     `db:"modified_on"`
	ExitedOn   *time.Time    `db:"exited_on"`
	ExitType   null.String   `db:"exit_type"`
	ExpiresOn  *time.Time    `db:"expires_on"`
	TimeoutOn  *time.Time    `db:"timeout_on"`
	Responded  bool          `db:"responded"`

	// TODO: should this be a complex object that can read / write iself to the DB as JSON?
	Results string `db:"results"`

	// TODO: should this be a complex object that can read / write iself to the DB as JSON?
	Path string `db:"path"`

	// TODO: should this be a complex object that can read / write iself to the DB as JSON?
	Events string `db:"events"`

	CurrentNodeUUID flows.NodeUUID  `db:"current_node_uuid"`
	ContactID       flows.ContactID `db:"contact_id"`
	FlowID          FlowID          `db:"flow_id"`
	OrgID           OrgID           `db:"org_id"`
	ParentID        null.Int        `db:"parent_id"`
	SessionID       SessionID       `db:"session_id"`
	StartID         null.Int        `db:"start_id"`
	// contains filtered or unexported fields
}

FlowRun is the mailroom type for a FlowRun

type Group added in v0.0.5

type Group struct {
	// contains filtered or unexported fields
}

Group is our mailroom type for contact groups

func (*Group) ID added in v0.0.5

func (g *Group) ID() GroupID

ID returns the ID for this group

func (*Group) Name added in v0.0.5

func (g *Group) Name() string

Name returns the name for this group

func (*Group) Query added in v0.0.5

func (g *Group) Query() string

Query returns the query string (if any) for this group

func (*Group) UUID added in v0.0.5

func (g *Group) UUID() assets.GroupUUID

UUID returns the uuid for this group

type GroupID added in v0.0.5

type GroupID int

type Label added in v0.0.5

type Label struct {
	// contains filtered or unexported fields
}

Label is our mailroom type for message labels

func (*Label) ID added in v0.0.5

func (l *Label) ID() LabelID

ID returns the ID for this label

func (*Label) Name added in v0.0.5

func (l *Label) Name() string

Name returns the name for this label

func (*Label) UUID added in v0.0.5

func (l *Label) UUID() assets.LabelUUID

UUID returns the uuid for this label

type LabelID added in v0.0.5

type LabelID int

type Location added in v0.0.5

type Location struct {
	Name_     string      `json:"name"`
	Aliases_  []string    `json:"aliases"`
	Children_ []*Location `json:"children"`
	// contains filtered or unexported fields
}

Location is our mailroom type for administrative locations TODO: convert to something less jank when we have real location constructors

func (*Location) Aliases added in v0.0.5

func (l *Location) Aliases() []string

Aliases returns the list of aliases for this location

func (*Location) Children added in v0.0.5

func (l *Location) Children() []*Location

Children returns the list of children for this location

func (*Location) ID added in v0.0.5

func (l *Location) ID() int

ID returns the database id for this location

func (*Location) Level added in v0.0.5

func (l *Location) Level() int

Level returns the level for this location

func (*Location) Name added in v0.0.5

func (l *Location) Name() string

Name returns the name for this location

func (*Location) OSMID added in v0.0.5

func (l *Location) OSMID() string

OSMID returns the OSM ID for this location

type Msg

type Msg struct {
	ID           flows.MsgID        `db:"id"              json:"id"`
	UUID         flows.MsgUUID      `db:"uuid"            json:"uuid"`
	Text         string             `db:"text"            json:"text"`
	HighPriority bool               `db:"high_priority"   json:"high_priority"`
	CreatedOn    time.Time          `db:"created_on"      json:"created_on"`
	ModifiedOn   time.Time          `db:"modified_on"     json:"modified_on"`
	SentOn       time.Time          `db:"sent_on"         json:"sent_on"`
	QueuedOn     time.Time          `db:"queued_on"       json:"queued_on"`
	Direction    MsgDirection       `db:"direction"       json:"direction"`
	Status       MsgStatus          `db:"status"          json:"status"`
	Visibility   MsgVisibility      `db:"visibility"      json:"visibility"`
	MsgType      MsgType            `db:"msg_type"`
	MsgCount     int                `db:"msg_count"       json:"tps_cost"`
	ErrorCount   int                `db:"error_count"     json:"error_count"`
	NextAttempt  time.Time          `db:"next_attempt"    json:"next_attempt"`
	ExternalID   null.String        `db:"external_id"     json:"external_id"`
	Attachments  pq.StringArray     `db:"attachments"     json:"attachments"`
	Metadata     null.String        `db:"metadata"        json:"metadata"`
	ChannelID    ChannelID          `db:"channel_id"      json:"channel_id"`
	ChannelUUID  assets.ChannelUUID `                     json:"channel_uuid"`
	ConnectionID ConnectionID       `db:"connection_id"`
	ContactID    flows.ContactID    `db:"contact_id"      json:"contact_id"`
	ContactURNID ContactURNID       `db:"contact_urn_id"  json:"contact_urn_id"`
	URN          urns.URN           `                     json:"urn"`
	URNAuth      string             `                     json:"urn_auth,omitempty"`
	OrgID        OrgID              `db:"org_id"          json:"org_id"`
	TopUpID      TopupID            `db:"topup_id"`
	// contains filtered or unexported fields
}

Msg is our type for mailroom messages

func NewOutgoingMsg added in v0.0.17

func NewOutgoingMsg(ctx context.Context, tx *sqlx.Tx, rp *redis.Pool, orgID OrgID, channel *Channel, contactID flows.ContactID, m *flows.MsgOut, createdOn time.Time) (*Msg, error)

NewOutgoingMsg creates an outgoing message for the passed in flow message. Note that this message is created in a queued state!

func (*Msg) Channel added in v0.0.5

func (m *Msg) Channel() *Channel

Channel returns the db channel object for this channel

type MsgDirection

type MsgDirection string

type MsgStatus

type MsgStatus string

type MsgType

type MsgType string

type MsgVisibility

type MsgVisibility string

type OffsetUnit added in v0.0.17

type OffsetUnit string

OffsetUnit defines what time unit our offset is in

type Org added in v0.0.5

type Org struct {
	// contains filtered or unexported fields
}

Org is mailroom's type for RapidPro orgs. It also implements the utils.Environment interface for GoFlow

func (*Org) DateFormat added in v0.0.5

func (o *Org) DateFormat() utils.DateFormat

DateFormat returns the date format for this org

func (*Org) Extension added in v0.0.5

func (o *Org) Extension(name string) json.RawMessage

Extension returns the extension for this org

func (*Org) ID added in v0.0.5

func (o *Org) ID() OrgID

ID returns the id of the org

func (*Org) Languages added in v0.0.5

func (o *Org) Languages() utils.LanguageList

Languages returns the list of supported languages for this org

func (*Org) MarshalJSON added in v0.0.22

func (o *Org) MarshalJSON() ([]byte, error)

MarshalJSON is our custom marshaller so that our inner env get output

func (*Org) Now added in v0.0.5

func (o *Org) Now() time.Time

Now returns the current time in the current timezone for this org

func (*Org) RedactionPolicy added in v0.0.5

func (o *Org) RedactionPolicy() utils.RedactionPolicy

RedactionPolicy returns the redaction policy (are we anonymous) for this org

func (*Org) TimeFormat added in v0.0.5

func (o *Org) TimeFormat() utils.TimeFormat

TimeFormat returns the time format for this org

func (*Org) Timezone added in v0.0.5

func (o *Org) Timezone() *time.Location

Timezone returns the timezone for this org

type OrgAssets

type OrgAssets struct {
	// contains filtered or unexported fields
}

func GetOrgAssets added in v0.0.5

func GetOrgAssets(ctx context.Context, db *sqlx.DB, orgID OrgID) (*OrgAssets, error)

GetOrgAssets creates or gets org assets for the passed in org

func (*OrgAssets) CampaignByGroupID added in v0.0.17

func (a *OrgAssets) CampaignByGroupID(groupID GroupID) []*Campaign

func (*OrgAssets) CampaignEventsByFieldID added in v0.0.17

func (a *OrgAssets) CampaignEventsByFieldID(fieldID FieldID) []*CampaignEvent

func (*OrgAssets) Campaigns added in v0.0.17

func (a *OrgAssets) Campaigns() []*Campaign

func (*OrgAssets) ChannelByID added in v0.0.5

func (a *OrgAssets) ChannelByID(channelID ChannelID) *Channel

func (*OrgAssets) ChannelByUUID added in v0.0.5

func (a *OrgAssets) ChannelByUUID(channelUUID assets.ChannelUUID) *Channel

func (*OrgAssets) Channels added in v0.0.5

func (a *OrgAssets) Channels() ([]assets.Channel, error)

func (*OrgAssets) Env added in v0.0.5

func (a *OrgAssets) Env() utils.Environment

func (*OrgAssets) FieldByKey added in v0.0.17

func (a *OrgAssets) FieldByKey(key string) *Field

func (*OrgAssets) FieldByUUID added in v0.0.5

func (a *OrgAssets) FieldByUUID(fieldUUID FieldUUID) *Field

func (*OrgAssets) Fields added in v0.0.5

func (a *OrgAssets) Fields() ([]assets.Field, error)

func (*OrgAssets) Flow added in v0.0.5

func (a *OrgAssets) Flow(flowUUID assets.FlowUUID) (assets.Flow, error)

func (*OrgAssets) GroupByID added in v0.0.5

func (a *OrgAssets) GroupByID(groupID GroupID) *Group

func (*OrgAssets) GroupByUUID added in v0.0.5

func (a *OrgAssets) GroupByUUID(groupUUID assets.GroupUUID) *Group

func (*OrgAssets) Groups added in v0.0.5

func (a *OrgAssets) Groups() ([]assets.Group, error)

func (*OrgAssets) Labels added in v0.0.5

func (a *OrgAssets) Labels() ([]assets.Label, error)

func (*OrgAssets) Locations added in v0.0.5

func (a *OrgAssets) Locations() ([]assets.LocationHierarchy, error)

func (*OrgAssets) OrgID added in v0.0.5

func (a *OrgAssets) OrgID() OrgID

func (*OrgAssets) Resthooks added in v0.0.5

func (a *OrgAssets) Resthooks() ([]assets.Resthook, error)

type OrgID

type OrgID int

type Resthook added in v0.0.5

type Resthook struct {
	// contains filtered or unexported fields
}

Resthook is the mailroom type for resthooks

func (*Resthook) ID added in v0.0.5

func (r *Resthook) ID() ResthookID

ID returns the ID of this resthook

func (*Resthook) Slug added in v0.0.5

func (r *Resthook) Slug() string

Slug returns the slug for this resthook

func (*Resthook) Subscribers added in v0.0.5

func (r *Resthook) Subscribers() []string

Subscribers returns the subscribers for this resthook

type ResthookID added in v0.0.5

type ResthookID int64

ResthookID is our type for the database id of a resthook

type Session

type Session struct {
	ID        SessionID       `db:"id"`
	Status    SessionStatus   `db:"status"`
	Responded bool            `db:"responded"`
	Output    string          `db:"output"`
	ContactID flows.ContactID `db:"contact_id"`
	OrgID     OrgID           `db:"org_id"`
	CreatedOn time.Time
	// contains filtered or unexported fields
}

Session is the mailroom type for a FlowSession

func NewSession added in v0.0.17

func NewSession(org *OrgAssets, s flows.Session) (*Session, error)

NewSession a session objects from the passed in flow session. It does NOT commit said session to the database.

func WriteSessions added in v0.0.10

func WriteSessions(ctx context.Context, tx *sqlx.Tx, rp *redis.Pool, org *OrgAssets, ss []flows.Session, hook SessionCommitHook) ([]*Session, error)

WriteSessions writes the passed in session to our database, writes any runs that need to be created as well as appying any events created in the session

func (*Session) AddPostCommitEvent added in v0.0.17

func (s *Session) AddPostCommitEvent(hook EventCommitHook, event interface{})

AddPostCommitEvent adds a new event to be handled by a post commit hook

func (*Session) AddPreCommitEvent added in v0.0.17

func (s *Session) AddPreCommitEvent(hook EventCommitHook, event interface{})

AddPreCommitEvent adds a new event to be handled by a pre commit hook

func (*Session) Contact added in v0.0.17

func (s *Session) Contact() *flows.Contact

Contact returns the contact for this session

func (*Session) ContactUUID added in v0.0.17

func (s *Session) ContactUUID() flows.ContactUUID

ContactUUID returns the UUID of our contact

func (*Session) Org added in v0.0.17

func (s *Session) Org() *OrgAssets

Org returns the org assets for this session

func (*Session) Runs added in v0.0.17

func (s *Session) Runs() []*FlowRun

Runs returns our flow run

type SessionCommitHook added in v0.0.19

type SessionCommitHook func(context.Context, *sqlx.Tx, *redis.Pool, *OrgAssets, []*Session) error

type SessionID

type SessionID int64

type SessionStatus

type SessionStatus string

type Step

type Step struct {
	UUID      flows.StepUUID `json:"uuid"`
	NodeUUID  flows.NodeUUID `json:"node_uuid"`
	ArrivedOn time.Time      `json:"arrived_on"`
	ExitUUID  flows.ExitUUID `json:"exit_uuid,omitempty"`
}

Step represents a single step in a run, this struct is used for serialization to the steps

type Topup added in v0.0.10

type Topup struct {
	ID         TopupID   `db:"id"`
	Remaining  int       `db:"remaining"`
	Expiration time.Time `db:"expires_on"`
}

Topup is our internal struct representing an org's topup and expiration date

type TopupID added in v0.0.10

type TopupID null.Int

TopupID is our type for topup ids, which can be null

func DecrementOrgCredits added in v0.0.17

func DecrementOrgCredits(ctx context.Context, db sqlx.Queryer, rc redis.Conn, orgID OrgID, amount int) (TopupID, error)

Jump to

Keyboard shortcuts

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