domain

package
v0.0.0-...-5ff6d09 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ScheduleExceptionKindYearMonthDay = "yearmonthday"
View Source
const ScheduleKindSchedules = "schedules"
View Source
const ScheduleKindWeekdayAndTime = "weekdayandtime"

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

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

genconstructor

func NewAdmin

func NewAdmin(
	id AdminID,
	name string,
) Admin

func (Admin) ID

func (m Admin) ID() AdminID

func (Admin) Name

func (m Admin) Name() string

func (*Admin) Rename

func (m *Admin) Rename(s string)

type AdminID

type AdminID string

type Answer

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

genconstructor

func NewAnswer

func NewAnswer(
	id AnswerID,
	questionnaireID QuestionnaireID,
	questionID QuestionID,
	answererID AnswererID,
	answeredAt time.Time,
	value string,
) Answer

func RestoreAnswerFromDumped

func RestoreAnswerFromDumped(v AnswerValue) Answer

func (Answer) AnsweredAt

func (m Answer) AnsweredAt() time.Time

func (Answer) AnswererID

func (m Answer) AnswererID() AnswererID

func (Answer) Dump

func (m Answer) Dump() AnswerValue

func (Answer) ID

func (m Answer) ID() AnswerID

func (*Answer) Overwrite

func (m *Answer) Overwrite(s string)

func (Answer) QuestionID

func (m Answer) QuestionID() QuestionID

func (Answer) QuestionnaireID

func (m Answer) QuestionnaireID() QuestionnaireID

func (Answer) Value

func (m Answer) Value() string

type AnswerID

type AnswerID string

type AnswerValue

type AnswerValue struct {
	ID              AnswerID `dynamo:",hash"`
	QuestionnaireID QuestionnaireID
	QuestionID      QuestionID
	AnswererID      AnswererID
	AnsweredAt      time.Time
	Value           string
}

type Answerer

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

genconstructor

func NewAnswerer

func NewAnswerer(
	id AnswererID,
	name string,
) Answerer

func RestoreAnswererFromDumped

func RestoreAnswererFromDumped(v AnswererValue) Answerer

func (Answerer) Dump

func (m Answerer) Dump() AnswererValue

func (Answerer) ID

func (m Answerer) ID() AnswererID

func (Answerer) Name

func (m Answerer) Name() string

func (Answerer) NotificationTargets

func (m Answerer) NotificationTargets() []NotificationTarget

func (*Answerer) Rename

func (m *Answerer) Rename(s string)

type AnswererID

type AnswererID string

type AnswererSearcher

type AnswererSearcher interface {
	FetchAll(ctx context.Context) ([]Answerer, Error)
}

type AnswererValue

type AnswererValue struct {
	ID                  AnswererID `dynamo:",hash"`
	Name                string
	NotificationTargets []NotificationTargetValue
}

type AskingService

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

genconstructor

func NewAskingService

func NewAskingService(
	questionnaireSearcher QuestionnaireSearcher,
	notificationTargetSearcher NotificationTargetSearcher,
	notificationService NotificationService,
	lastExecutedRecorder LastExecutedRecorder,
) AskingService

func (AskingService) AskAllIfNeeded

func (s AskingService) AskAllIfNeeded(ctx context.Context) Error

func (AskingService) AskQuestionnaire

func (s AskingService) AskQuestionnaire(ctx context.Context, questionnaire Questionnaire) Error

func (*AskingService) OverwriteNowFunc

func (m *AskingService) OverwriteNowFunc(s func() time.Time)

type Error

type Error interface {
	Error() string
	Details() []ErrorDetail

	IsUnknown() bool
	IsBadRequest() bool
	IsPermissionDenied() bool
	IsNotFound() bool
}

func ErrorBadRequest

func ErrorBadRequest(source error, details ...ErrorDetail) Error

func ErrorNotFound

func ErrorNotFound(source error, details ...ErrorDetail) Error

func ErrorPermissionDenied

func ErrorPermissionDenied(source error, details ...ErrorDetail) Error

func ErrorUnknown

func ErrorUnknown(source error, details ...ErrorDetail) Error

type ErrorCode

type ErrorCode string

func (ErrorCode) String

func (c ErrorCode) String() string

type ErrorDetail

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

func QuestionIsNotFoundError

func QuestionIsNotFoundError(
	questionID QuestionID,
) ErrorDetail

func (ErrorDetail) Args

func (c ErrorDetail) Args() []string

func (ErrorDetail) Code

func (c ErrorDetail) Code() ErrorDetailCode

func (ErrorDetail) String

func (e ErrorDetail) String() string

type ErrorDetailCode

type ErrorDetailCode string
const ErrorDetailQuestionIsNotFound ErrorDetailCode = "QuestionIsNotFound"

func (ErrorDetailCode) String

func (c ErrorDetailCode) String() string

type LastExecutedRecorder

type LastExecutedRecorder interface {
	RecordLastExecuted(ctx context.Context, questionnaire Questionnaire, lastExecuted time.Time) Error
}

type NotificationService

type NotificationService interface {
	Notify(ctx context.Context, notificationTarget NotificationTarget, questionnaire Questionnaire) Error
}

type NotificationTarget

type NotificationTarget interface {
	ID() NotificationTargetID
	QuestionnaireID() QuestionnaireID
	AnswererID() AnswererID
	NotificationTargetKind() NotificationTargetKind
	Dump() NotificationTargetValue
}

func RestoreNotificationTargetFromDumped

func RestoreNotificationTargetFromDumped(v NotificationTargetValue) NotificationTarget

type NotificationTargetBase

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

genconstructor

func NewNotificationTargetBase

func NewNotificationTargetBase(
	id NotificationTargetID,
	questionnaireID QuestionnaireID,
	answererID AnswererID,
) NotificationTargetBase

func RestoreNotificationTargetBaseFromDumped

func RestoreNotificationTargetBaseFromDumped(v NotificationTargetValue) NotificationTargetBase

func (NotificationTargetBase) AnswererID

func (m NotificationTargetBase) AnswererID() AnswererID

func (NotificationTargetBase) Dump

func (NotificationTargetBase) ID

func (NotificationTargetBase) NotificationTargetKind

func (m NotificationTargetBase) NotificationTargetKind() NotificationTargetKind

func (NotificationTargetBase) QuestionnaireID

func (m NotificationTargetBase) QuestionnaireID() QuestionnaireID

type NotificationTargetID

type NotificationTargetID string

type NotificationTargetKind

type NotificationTargetKind string
const (
	NotificationTargetKindBase  NotificationTargetKind = "base"
	NotificationTargetKindSlack NotificationTargetKind = "slack"
)

type NotificationTargetSearcher

type NotificationTargetSearcher interface {
	SearchByQuestionnaireIDAndAnswererID(ctx context.Context, questionnaireID QuestionnaireID, answererID AnswererID) ([]NotificationTarget, Error)
	SearchByQuestionnaireID(ctx context.Context, questionnaireID QuestionnaireID) ([]NotificationTarget, Error)
}

type NotificationTargetSlack

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

genconstructor

func NewNotificationTargetSlack

func NewNotificationTargetSlack(
	id NotificationTargetID,
	questionnaireID QuestionnaireID,
	answererID AnswererID,
	channelID string,
	userID string,
) NotificationTargetSlack

func RestoreNotificationTargetSlackFromDumped

func RestoreNotificationTargetSlackFromDumped(v NotificationTargetValue) NotificationTargetSlack

func (NotificationTargetSlack) AnswererID

func (m NotificationTargetSlack) AnswererID() AnswererID

func (NotificationTargetSlack) ChannelID

func (m NotificationTargetSlack) ChannelID() string

func (NotificationTargetSlack) Dump

func (NotificationTargetSlack) ID

func (NotificationTargetSlack) NeedsMention

func (m NotificationTargetSlack) NeedsMention() bool

func (NotificationTargetSlack) NotificationTargetKind

func (m NotificationTargetSlack) NotificationTargetKind() NotificationTargetKind

func (NotificationTargetSlack) QuestionnaireID

func (m NotificationTargetSlack) QuestionnaireID() QuestionnaireID

func (*NotificationTargetSlack) ToggleNeedsMention

func (m *NotificationTargetSlack) ToggleNeedsMention(s bool)

func (NotificationTargetSlack) UserID

func (m NotificationTargetSlack) UserID() string

type NotificationTargetValue

type NotificationTargetValue struct {
	ID                     NotificationTargetID `dynamo:",hash"`
	QuestionnaireID        QuestionnaireID
	AnswererID             AnswererID
	NotificationTargetKind NotificationTargetKind

	ChannelID    string
	UserID       string
	NeedsMention bool
}

type PostTarget

type PostTarget interface {
	ID() PostTargetID
	PostTargetKind() PostTargetKind
	Dump() PostTargetValue
}

func RestorePostTargetFromDumpled

func RestorePostTargetFromDumpled(v PostTargetValue) PostTarget

type PostTargetBase

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

genconstructor

func NewPostTargetBase

func NewPostTargetBase(
	id PostTargetID,
) PostTargetBase

func RestorePostTargetBaseFromDumped

func RestorePostTargetBaseFromDumped(v PostTargetValue) PostTargetBase

func (PostTargetBase) Dump

func (PostTargetBase) ID

func (PostTargetBase) PostTargetKind

func (m PostTargetBase) PostTargetKind() PostTargetKind

type PostTargetID

type PostTargetID string

type PostTargetKind

type PostTargetKind string
const (
	PostTargetKindBase  PostTargetKind = "base"
	PostTargetKindSlack PostTargetKind = "slack"
)

type PostTargetSlack

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

genconstructor

func NewPostTargetSlack

func NewPostTargetSlack(
	id PostTargetID,
	channelID string,
) PostTargetSlack

func RestorePostTargetSlackFromDumped

func RestorePostTargetSlackFromDumped(v PostTargetValue) PostTargetSlack

func (PostTargetSlack) ChannelID

func (m PostTargetSlack) ChannelID() string

func (PostTargetSlack) Dump

func (PostTargetSlack) ID

func (PostTargetSlack) PostTargetKind

func (m PostTargetSlack) PostTargetKind() PostTargetKind

type PostTargetValue

type PostTargetValue struct {
	ID             PostTargetID
	PostTargetKind PostTargetKind

	ChannelID string
}

type PostingService

type PostingService interface {
	PostAnswers(ctx context.Context, questionnaire Questionnaire, answerer Answerer, answers []Answer) Error
}

type Question

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

genconstructor

func NewQuestion

func NewQuestion(
	id QuestionID,
	text string,
) Question

func RestoreQuestionFromDumped

func RestoreQuestionFromDumped(v QuestionValue) Question

func (Question) Dump

func (m Question) Dump() QuestionValue

func (Question) ID

func (m Question) ID() QuestionID

func (*Question) Overwrite

func (m *Question) Overwrite(s string)

func (*Question) SetSuggestingFunc

func (m *Question) SetSuggestingFunc(s func(currentText string) []string)

func (*Question) SetValidatingFunc

func (m *Question) SetValidatingFunc(s func(currentText string) Error)

func (Question) SuggestingFunc

func (m Question) SuggestingFunc() func(currentText string) []string

func (Question) Text

func (m Question) Text() string

func (Question) ValidatingFunc

func (m Question) ValidatingFunc() func(currentText string) Error

type QuestionID

type QuestionID string

type QuestionItem

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

genconstructor

func NewQuestionItem

func NewQuestionItem(
	question Question,
	required bool,
) QuestionItem

func (QuestionItem) Question

func (m QuestionItem) Question() Question

func (QuestionItem) Required

func (m QuestionItem) Required() bool

type QuestionItemValue

type QuestionItemValue struct {
	Question QuestionValue
	Required bool
}

type QuestionValue

type QuestionValue struct {
	ID   QuestionID
	Text string
}

type Questionnaire

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

genconstructor

func NewQuestionnaire

func NewQuestionnaire(
	id QuestionnaireID,
	title string,
	questionItems []QuestionItem,
) Questionnaire

func RestoreQuestionnaireFromDumped

func RestoreQuestionnaireFromDumped(v QuestionnaireValue) Questionnaire

func (Questionnaire) Answer

func (q Questionnaire) Answer(answerID AnswerID, questionID QuestionID, answererID AnswererID, value string) (Answer, Error)

func (Questionnaire) Dump

func (Questionnaire) ID

func (Questionnaire) LastExecuted

func (m Questionnaire) LastExecuted() time.Time

func (*Questionnaire) OverwriteTitle

func (m *Questionnaire) OverwriteTitle(s string)

func (Questionnaire) PostTargets

func (m Questionnaire) PostTargets() []PostTarget

func (Questionnaire) QuestionItems

func (m Questionnaire) QuestionItems() []QuestionItem

func (*Questionnaire) ReplaceQuestions

func (m *Questionnaire) ReplaceQuestions(s []QuestionItem)

func (Questionnaire) Schedule

func (m Questionnaire) Schedule() Schedule

func (*Questionnaire) SetLastExecuted

func (m *Questionnaire) SetLastExecuted(s time.Time)

func (*Questionnaire) SetPostTargets

func (m *Questionnaire) SetPostTargets(s []PostTarget)

func (*Questionnaire) SetSchedule

func (m *Questionnaire) SetSchedule(s Schedule)

func (Questionnaire) Title

func (m Questionnaire) Title() string

type QuestionnaireID

type QuestionnaireID string

type QuestionnaireSearcher

type QuestionnaireSearcher interface {
	SearchExecutionNeeded(ctx context.Context) ([]Questionnaire, Error)
	FetchAll(ctx context.Context) ([]Questionnaire, Error)
	FindByID(ctx context.Context, id QuestionnaireID) (questionnaire Questionnaire, version int, derr Error)
}

type QuestionnaireTarget

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

genconstructor

func NewQuestionnaireTarget

func NewQuestionnaireTarget(
	id QuestionnaireTargetID,
	questionnaireID QuestionnaireID,
	targetType QuestionnaireTargetType,
	targetIDs []string,
	schedules []Schedule,
	scheduleExceptions []ScheduleException,
) QuestionnaireTarget

func (QuestionnaireTarget) ID

func (QuestionnaireTarget) QuestionnaireID

func (m QuestionnaireTarget) QuestionnaireID() QuestionnaireID

func (QuestionnaireTarget) ScheduleExceptions

func (m QuestionnaireTarget) ScheduleExceptions() []ScheduleException

func (QuestionnaireTarget) Schedules

func (m QuestionnaireTarget) Schedules() []Schedule

func (*QuestionnaireTarget) SetScheduleExceptions

func (m *QuestionnaireTarget) SetScheduleExceptions(s []ScheduleException)

func (*QuestionnaireTarget) SetSchedules

func (m *QuestionnaireTarget) SetSchedules(s []Schedule)

func (*QuestionnaireTarget) SetTargetIDs

func (m *QuestionnaireTarget) SetTargetIDs(s []string)

func (QuestionnaireTarget) TargetIDs

func (m QuestionnaireTarget) TargetIDs() []string

func (QuestionnaireTarget) TargetType

type QuestionnaireTargetID

type QuestionnaireTargetID string

type QuestionnaireTargetType

type QuestionnaireTargetType string

type QuestionnaireValue

type QuestionnaireValue struct {
	ID            QuestionnaireID `dynamo:",hash"`
	Title         string
	QuestionItems []QuestionItemValue
	Schedule      ScheduleValue
	PostTargets   []PostTargetValue
	LastExecuted  time.Time
	NextTime      time.Time
	NextTimeUnix  int64
}

type Schedule

type Schedule interface {
	NextTime(baseTime time.Time) time.Time
	PrevTime(baseTime time.Time) time.Time
	Dump() ScheduleValue
	ScheduleKind() ScheduleKind
}

func RestoreScheduleFromDumped

func RestoreScheduleFromDumped(v ScheduleValue) Schedule

type ScheduleException

type ScheduleException interface {
	NeedsIgnore(time.Time) bool
	Dump() ScheduleExceptionValue
	ScheduleExceptionKind() ScheduleExceptionKind
}

func RestoreScheduleExceptionFromDumped

func RestoreScheduleExceptionFromDumped(v ScheduleExceptionValue) ScheduleException

type ScheduleExceptionKind

type ScheduleExceptionKind string

type ScheduleExceptionValue

type ScheduleExceptionValue struct {
	ScheduleExceptionKind ScheduleExceptionKind
	Year                  uint32
	Month                 time.Month
	Day                   uint32
	LocOffset             int
}

type ScheduleKind

type ScheduleKind string

type ScheduleValue

type ScheduleValue struct {
	ScheduleKind ScheduleKind

	Hour      uint32
	Minute    uint32
	Sec       uint32
	LocOffset int
	Mon       bool
	Tue       bool
	Wed       bool
	Thu       bool
	Fri       bool
	Sat       bool
	Sun       bool

	Schedules  []ScheduleValue
	Exceptions []ScheduleExceptionValue
}

type Schedules

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

func NewSchedules

func NewSchedules(
	baseSchedule Schedule,
	additionalSchedules []Schedule,
	exceptions []ScheduleException,
) Schedules

func RestoreSchedulesFromDumped

func RestoreSchedulesFromDumped(v ScheduleValue) Schedules

func (Schedules) Dump

func (s Schedules) Dump() ScheduleValue

func (Schedules) Exceptions

func (m Schedules) Exceptions() []ScheduleException

func (Schedules) NextTime

func (s Schedules) NextTime(baseTime time.Time) time.Time

func (Schedules) PrevTime

func (s Schedules) PrevTime(baseTime time.Time) time.Time

func (Schedules) ScheduleKind

func (m Schedules) ScheduleKind() ScheduleKind

func (Schedules) Schedules

func (m Schedules) Schedules() []Schedule

type WeekdayAndTimeSchedule

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

genconstructor

func NewWeekdayAndTimeSchedule

func NewWeekdayAndTimeSchedule(
	hour uint32,
	minute uint32,
	sec uint32,
	locOffset int,
	mon bool,
	tue bool,
	wed bool,
	thu bool,
	fri bool,
	sat bool,
	sun bool,
) WeekdayAndTimeSchedule

func RestoreScheduleWeekdayAndTimeFromDumpled

func RestoreScheduleWeekdayAndTimeFromDumpled(v ScheduleValue) WeekdayAndTimeSchedule

func (WeekdayAndTimeSchedule) Dump

func (WeekdayAndTimeSchedule) Fri

func (m WeekdayAndTimeSchedule) Fri() bool

func (WeekdayAndTimeSchedule) Hour

func (m WeekdayAndTimeSchedule) Hour() uint32

func (WeekdayAndTimeSchedule) LocOffset

func (m WeekdayAndTimeSchedule) LocOffset() int

func (WeekdayAndTimeSchedule) Minute

func (m WeekdayAndTimeSchedule) Minute() uint32

func (WeekdayAndTimeSchedule) Mon

func (m WeekdayAndTimeSchedule) Mon() bool

func (WeekdayAndTimeSchedule) NextTime

func (s WeekdayAndTimeSchedule) NextTime(baseTime time.Time) time.Time

func (WeekdayAndTimeSchedule) PrevTime

func (s WeekdayAndTimeSchedule) PrevTime(baseTime time.Time) time.Time

func (WeekdayAndTimeSchedule) Sat

func (m WeekdayAndTimeSchedule) Sat() bool

func (WeekdayAndTimeSchedule) ScheduleKind

func (m WeekdayAndTimeSchedule) ScheduleKind() ScheduleKind

func (WeekdayAndTimeSchedule) Sec

func (WeekdayAndTimeSchedule) Sun

func (m WeekdayAndTimeSchedule) Sun() bool

func (WeekdayAndTimeSchedule) Thu

func (m WeekdayAndTimeSchedule) Thu() bool

func (WeekdayAndTimeSchedule) Tue

func (m WeekdayAndTimeSchedule) Tue() bool

func (WeekdayAndTimeSchedule) Wed

func (m WeekdayAndTimeSchedule) Wed() bool

type YearMonthDayScheduleException

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

genconstructor

func NewYearMonthDayScheduleException

func NewYearMonthDayScheduleException(
	year uint32,
	month time.Month,
	day uint32,
	locOffset int,
) YearMonthDayScheduleException

func (YearMonthDayScheduleException) Day

func (YearMonthDayScheduleException) Dump

func (YearMonthDayScheduleException) LocOffset

func (m YearMonthDayScheduleException) LocOffset() int

func (YearMonthDayScheduleException) Month

func (YearMonthDayScheduleException) NeedsIgnore

func (s YearMonthDayScheduleException) NeedsIgnore(t time.Time) bool

func (YearMonthDayScheduleException) ScheduleExceptionKind

func (m YearMonthDayScheduleException) ScheduleExceptionKind() ScheduleExceptionKind

func (YearMonthDayScheduleException) Year

Directories

Path Synopsis
Package mock_domain is a generated GoMock package.
Package mock_domain is a generated GoMock package.

Jump to

Keyboard shortcuts

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