rules

package
v0.0.0-...-047823a Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: Unlicense Imports: 11 Imported by: 0

Documentation

Overview

Package rules provides means to manage rules in persistence

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomData

type CustomData map[string]any

CustomData is what could be sent in, data of any shape

type ExecutableRule

type ExecutableRule struct {
	ID   string
	Name string
	Ast  *cel.Ast
}

ExecutableRule contains all needed to evaluate a Transaction

type MongoStore

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

MongoStore holds all needed to manage rules

func (*MongoStore) Create

func (m *MongoStore) Create(ctx context.Context, rule NewRule) (any, error)

Create inserts one NewRule into a mongo DB

func (*MongoStore) Read

func (m *MongoStore) Read(ctx context.Context, userID string, entityID string) ([]ExecutableRule, error)

Read queries the DB and returns all applicable rules

type NewRule

type NewRule struct {
	Name       string
	UserID     string
	Definition string
	IsActive   bool
	Included   []string
	Excluded   []string
}

NewRule contains all needed to insert a new rule

type PgStore

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

PgStore holds all needed to manage rules in a postgres DB

func (*PgStore) Create

func (s *PgStore) Create(ctx context.Context, rule NewRule) (string, error)

Create inserts one NewRule into a postgres DB

func (*PgStore) Read

func (s *PgStore) Read(ctx context.Context, userID string, entityID string) ([]ExecutableRule, error)

Read queries the DB and returns all applicable rules

type Txn

type Txn struct {
	Name          string
	Type          string
	Currency      string
	Amount        float64
	RiskScore     int
	CustomData    CustomData
	CustomBools   map[string]bool
	CustomFloats  map[string]float64
	CustomStrings map[string]string
	Aggregates    map[string]float64
}

Txn is the model for a transaction

Jump to

Keyboard shortcuts

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