Documentation ¶
Index ¶
- func Contains(identifiers []TupleType, toCheck TupleType) (bool, int)
- func IdentifiersToString(identifiers []TupleType) string
- func RegisterTupleDescriptors(jsonRegistry string) (err error)
- func RegisterTupleDescriptorsFromTds(tds []TupleDescriptor) (err error)
- type ActionFunction
- type Condition
- type ConditionEvaluator
- type MutableRule
- type MutableTuple
- type RetecontextKeyType
- type RtcModified
- type RtcTransactionHandler
- type RtcTxn
- type Rule
- type RuleContext
- type RuleSession
- type StartupRSFunction
- type Tuple
- type TupleDescriptor
- type TupleKey
- type TuplePropertyDescriptor
- type TupleType
- type ValueChangeListener
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IdentifiersToString ¶
IdentifiersToString Take a slice of Identifiers and return a string representation
func RegisterTupleDescriptors ¶
RegisterTupleDescriptors registers the TupleDescriptors
func RegisterTupleDescriptorsFromTds ¶
func RegisterTupleDescriptorsFromTds(tds []TupleDescriptor) (err error)
RegisterTupleDescriptors registers the TupleDescriptors
Types ¶
type ActionFunction ¶
type ActionFunction func(context.Context, RuleSession, string, map[TupleType]Tuple, RuleContext)
ActionFunction is a function pointer for handling action callbacks on the server side i.e part of the server side API
type Condition ¶
type Condition interface { GetName() string GetRule() Rule GetIdentifiers() []TupleType GetContext() RuleContext String() string Evaluate(string, string, map[TupleType]Tuple, RuleContext) (bool, error) }
Condition interface to maintain/get various condition properties
type ConditionEvaluator ¶
ConditionEvaluator is a function pointer for handling condition evaluations on the server side i.e, part of the server side API
type MutableRule ¶
type MutableRule interface { Rule AddCondition(conditionName string, idrs []string, cFn ConditionEvaluator, ctx RuleContext) (err error) SetAction(actionFn ActionFunction) SetPriority(priority int) SetContext(ctx RuleContext) AddExprCondition(conditionName string, cExpr string, ctx RuleContext) error AddIdrsToRule(idrs []TupleType) }
MutableRule interface has methods to add conditions and actions
type MutableTuple ¶
type MutableTuple interface { Tuple SetString(ctx context.Context, name string, value string) (err error) SetInt(ctx context.Context, name string, value int) (err error) SetLong(ctx context.Context, name string, value int64) (err error) SetDouble(ctx context.Context, name string, value float64) (err error) SetBool(ctx context.Context, name string, value bool) (err error) //will try to coerce value to the named property's type SetValue(ctx context.Context, name string, value interface{}) (err error) }
MutableTuple mutable part of the tuple
func NewTuple ¶
func NewTuple(tupleType TupleType, values map[string]interface{}) (mtuple MutableTuple, err error)
func NewTupleWithKeyValues ¶
func NewTupleWithKeyValues(tupleType TupleType, values ...interface{}) (mtuple MutableTuple, err error)
type RetecontextKeyType ¶
type RetecontextKeyType struct { }
type RtcModified ¶
type RtcTransactionHandler ¶
type RtcTransactionHandler func(ctx context.Context, rs RuleSession, txn RtcTxn, txnContext interface{})
type Rule ¶
type Rule interface { GetName() string GetIdentifiers() []TupleType GetConditions() []Condition GetActionFn() ActionFunction String() string GetPriority() int GetDeps() map[TupleType]map[string]bool GetContext() RuleContext }
Rule ... a Rule interface
type RuleSession ¶
type RuleSession interface { GetName() string AddRule(rule Rule) (err error) DeleteRule(ruleName string) GetRules() []Rule Assert(ctx context.Context, tuple Tuple) (err error) Retract(ctx context.Context, tuple Tuple) ScheduleAssert(ctx context.Context, delayInMillis uint64, key interface{}, tuple Tuple) CancelScheduledAssert(ctx context.Context, key interface{}) Unregister() //Optional, called before asserting a tuple but after adding all rules SetStartupFunction(startupFn StartupRSFunction) GetStartupFunction() (startupFn StartupRSFunction) //To be called when the rule session is ready to start accepting tuples //This will invoke the StartupFunction Start(startupCtx map[string]interface{}) (err error) //return the asserted tuple, nil if not found GetAssertedTuple(key TupleKey) Tuple //Retract, and remove Delete(ctx context.Context, tuple Tuple) //RtcTransactionHandler RegisterRtcTransactionHandler(txnHandler RtcTransactionHandler, handlerCtx interface{}) //replay existing tuples into a rule ReplayTuplesForRule(ruleName string) (err error) }
RuleSession to maintain rules and assert tuples against those rules
type StartupRSFunction ¶
type StartupRSFunction func(ctx context.Context, rs RuleSession, sessionCtx map[string]interface{}) (err error)
StartupRSFunction is called once after creation of a RuleSession
type Tuple ¶
type Tuple interface { GetTupleType() TupleType GetTupleDescriptor() *TupleDescriptor GetProperties() []string GetString(name string) (val string, err error) GetInt(name string) (val int, err error) GetLong(name string) (val int64, err error) GetDouble(name string) (val float64, err error) GetBool(name string) (val bool, err error) //GetDateTime(name string) time.Time GetKey() TupleKey GetMap() map[string]interface{} }
Tuple is a runtime representation of a data tuple
type TupleDescriptor ¶
type TupleDescriptor struct { Name string `json:"name"` TTLInSeconds int `json:"ttl"` Props []TuplePropertyDescriptor `json:"properties"` // contains filtered or unexported fields }
TupleDescriptor defines the type of the structure, its properties, types
func GetTupleDescriptor ¶
func GetTupleDescriptor(tupleType TupleType) *TupleDescriptor
GetTupleDescriptor gets the TupleDescriptor based on the TupleType
func (*TupleDescriptor) GetKeyProps ¶
func (td *TupleDescriptor) GetKeyProps() []string
GetKeyProps returns all the key properties
func (*TupleDescriptor) GetProperty ¶
func (td *TupleDescriptor) GetProperty(prop string) *TuplePropertyDescriptor
GetProperty fetches the property by name
func (*TupleDescriptor) UnmarshalJSON ¶
func (td *TupleDescriptor) UnmarshalJSON(b []byte) error
type TupleKey ¶
type TupleKey interface { String() string GetTupleDescriptor() TupleDescriptor GetProps() []string GetValue(string) interface{} }
TupleKey primary key of a tuple
func NewTupleKey ¶
type TuplePropertyDescriptor ¶
type TuplePropertyDescriptor struct { Name string `json:"name"` PropType data.Type `json:"type"` KeyIndex int `json:"pk-index"` }
TuplePropertyDescriptor defines the actual property, its type, key index
func (TuplePropertyDescriptor) MarshalJSON ¶
func (tpd TuplePropertyDescriptor) MarshalJSON() ([]byte, error)
MarshalJSON allows to hook & customize TupleDescriptor to JSON conversion
type TupleType ¶
type TupleType string
TupleType Each tuple is of a certain type, described by TypeDescriptor
type ValueChangeListener ¶
ValueChangeListener to pickup and process tuple value changes