Documentation
¶
Index ¶
- Constants
- Variables
- func ExpressionEval(expression studyTypes.Expression, evalCtx EvalContext) (val interface{}, err error)
- func InitStudyEngine(dbService StudyDBService, externalServices []ExternalService)
- type ActionData
- type EvalContext
- type ExternalEventPayload
- type ExternalService
- type MutualTLSConfig
- type StudyDBService
- type StudyEngine
- type StudyEvent
Constants ¶
View Source
const ( STUDY_EVENT_TYPE_ENTER = "ENTER" STUDY_EVENT_TYPE_SUBMIT = "SUBMIT" STUDY_EVENT_TYPE_TIMER = "TIMER" STUDY_EVENT_TYPE_CUSTOM = "CUSTOM" STUDY_EVENT_TYPE_MERGE = "MERGE" STUDY_EVENT_TYPE_LEAVE = "LEAVE" )
Variables ¶
View Source
var Now func() time.Time = time.Now
Now function control the current time used by the expressions.
Functions ¶
func ExpressionEval ¶
func ExpressionEval(expression studyTypes.Expression, evalCtx EvalContext) (val interface{}, err error)
func InitStudyEngine ¶
func InitStudyEngine(dbService StudyDBService, externalServices []ExternalService)
Types ¶
type ActionData ¶
type ActionData struct { PState studyTypes.Participant ReportsToCreate map[string]studyTypes.Report }
func ActionEval ¶
func ActionEval(action studyTypes.Expression, oldState ActionData, event StudyEvent) (newState ActionData, err error)
type EvalContext ¶
type EvalContext struct { Event StudyEvent ParticipantState studyTypes.Participant }
EvalContext contains all the data that can be looked up by expressions
type ExternalEventPayload ¶
type ExternalEventPayload struct { ParticipantState studyTypes.Participant `json:"participantState"` EventType string `json:"eventType"` StudyKey string `json:"studyKey"` InstanceID string `json:"instanceID"` Response studyTypes.SurveyResponse `json:"surveyResponses"` EventKey string `json:"eventKey"` Payload map[string]interface{} `json:"payload"` }
type ExternalService ¶
type ExternalService struct { Name string `yaml:"name"` URL string `yaml:"url"` APIKey string `yaml:"apiKey"` Timeout int `yaml:"timeout"` MutualTLSConfig *MutualTLSConfig `yaml:"mTLSConfig"` }
type MutualTLSConfig ¶
type StudyDBService ¶
type StudyDBService interface { GetResponses(instanceID string, studyKey string, filter bson.M, sort bson.M, page int64, limit int64) (responses []studyTypes.SurveyResponse, paginationInfo *studyDB.PaginationInfos, err error) DeleteConfidentialResponses(instanceID string, studyKey string, participantID string, key string) (count int64, err error) SaveResearcherMessage(instanceID string, studyKey string, message studyTypes.StudyMessage) error StudyCodeListEntryExists(instanceID string, studyKey string, listKey string, code string) (bool, error) DeleteStudyCodeListEntry(instanceID string, studyKey string, listKey string, code string) error }
type StudyEngine ¶
type StudyEngine struct {
// contains filtered or unexported fields
}
var (
CurrentStudyEngine *StudyEngine
)
type StudyEvent ¶
type StudyEvent struct { InstanceID string StudyKey string Type string // what kind of event (TIMER, SUBMISSION, ENTER etc.) Response studyTypes.SurveyResponse // if something is submitted during the event is added here Payload map[string]interface{} // additional data EventKey string // key of the event (for custom events) MergeWithParticipant studyTypes.Participant // if need to merge with other participant state, is added here ParticipantIDForConfidentialResponses string }
Click to show internal directories.
Click to hide internal directories.