volantere

package
v0.0.0-...-0051623 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Rule engine for credit card

Author Bogdan Peta

Rule engine for Payment

Author Bogdan Peta

This is the interface with grule-rule-engine.

Represents the core of every rule engine derived from VolanteRuleEngine

Author Bogdan Peta

This is the rule engine root package that will hold multiple rule engines defined by various business rules

Implements the Factory design pattern

Conventions:

1. Every rule engine will live in a file with name of the rule engine in this package and in this directory.

2. Every rule engine will implement the interface VolanteRuleEngine.

3. Every rule engine will load its rules from the directory: $PATH_TO/volgre/rules/<rule_engine_name>/<version>.grl

Author Bogdan Peta

Index

Constants

View Source
const (
	CreditCardRuleEngineT = 1
	PaymentRuleEngineT    = 2
	NotExistentRuleEngine = 3
)

Variables

View Source
var LoadedRuleEngines map[string]VolanteRuleEngine = map[string]VolanteRuleEngine{}

Here will be pre-loaded the registered rules engines Singleton design pattern

View Source
var RegisteredRuleEngines map[string]int = map[string]int{
	"credit_card": CreditCardRuleEngineT,
	"payment":     PaymentRuleEngineT,
}

registered rules engines TODO: load them from a config file

Functions

This section is empty.

Types

type CreditCard

type CreditCard struct {
	Tenant         interface{} `json:"tenant"`
	MessageContent interface{} `json:"messageContent"`
	MessageType    string      `json:"messageType"`

	Result ValidationResult `json:"volgre:validationResults"`

	Rule_engine_execution_time string `json:"volgre:rule_engine_execution_time"`
}

func (*CreditCard) ValidateCardNumber

func (cc *CreditCard) ValidateCardNumber() bool

Rules data structure

func (*CreditCard) ValidateExpMonth

func (cc *CreditCard) ValidateExpMonth() bool

func (*CreditCard) ValidateExpYear

func (cc *CreditCard) ValidateExpYear() bool

func (*CreditCard) ValidateHolderName

func (cc *CreditCard) ValidateHolderName() bool

func (*CreditCard) ValidateSecurityCode

func (cc *CreditCard) ValidateSecurityCode() bool

type CreditCardRuleEngine

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

func (*CreditCardRuleEngine) Dump

func (ccre *CreditCardRuleEngine) Dump(fn func(interface{}) ([]byte, error)) (rez []byte)

func (*CreditCardRuleEngine) Init

func (ccre *CreditCardRuleEngine) Init(rule_path string) interface{}

func (*CreditCardRuleEngine) Load

func (ccre *CreditCardRuleEngine) Load(fn func(interface{}))

func (*CreditCardRuleEngine) Refresh

func (ccre *CreditCardRuleEngine) Refresh()

func (*CreditCardRuleEngine) Run

func (ccre *CreditCardRuleEngine) Run(data string) string

func (*CreditCardRuleEngine) Version

func (ccre *CreditCardRuleEngine) Version() string

type Payment

type Payment struct {
	Status string `json:"messageType"`
}

func (*Payment) CreateAuditLog

func (cc *Payment) CreateAuditLog(instr string)

func (*Payment) GenerateID

func (cc *Payment) GenerateID() string

Rules data structure

type PaymentRuleEngine

type PaymentRuleEngine struct {
	Data *Payment
	// contains filtered or unexported fields
}

func (*PaymentRuleEngine) Dump

func (ccre *PaymentRuleEngine) Dump(fn func(interface{}) ([]byte, error)) (rez []byte)

func (*PaymentRuleEngine) Init

func (ccre *PaymentRuleEngine) Init(rule_path string) interface{}

func (*PaymentRuleEngine) Load

func (ccre *PaymentRuleEngine) Load(fn func(interface{}))

func (*PaymentRuleEngine) Refresh

func (ccre *PaymentRuleEngine) Refresh()

func (*PaymentRuleEngine) Run

func (ccre *PaymentRuleEngine) Run(status string) string

func (*PaymentRuleEngine) Version

func (ccre *PaymentRuleEngine) Version() string

type RuleEngine

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

type ValidationResult

type ValidationResult struct {
	CardNumber bool `json:"cardNumber"`

	OwnerName bool `json:"ownerName"`

	ExpireMonth bool `json:"expireMonth"`

	ExpireYear bool `json:"expireYear"`

	SecurityCode bool `json:"securityCode"`

	Currency bool `json:"currency"`

	Amount bool `json:"amount"`
}

type VolanteRuleEngine

type VolanteRuleEngine interface {
	Init(rule_path string) interface{}
	Load(f func(interface{}))
	Dump(f func(interface{}) ([]byte, error)) []byte
	Run(data string) string
	Refresh()
	Version() string
}

func GetRuleEngine

func GetRuleEngine(m int) (VolanteRuleEngine, error)

Jump to

Keyboard shortcuts

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