servicebuildermdl

package
v2.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package servicebuildermdl will help you run BL and fetch data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGlobalConfig

func SetGlobalConfig(configs map[string]GlobalConfigModel)

SetGlobalConfig - SetGlobalConfig

Types

type APIResponse

type APIResponse struct {
	StatusCode int
	Body       []byte
	Headers    []Header
}

APIResponse - APIResponse

type AbstractBusinessLogicHolder

type AbstractBusinessLogicHolder struct {
	GlobalErrorCode   int
	ServiceError      interface{}
	TransactionEnable bool
	DatabaseType      string // database type for transaction begin(MYSQL,SQLSERVER etc.)
	IgnoreStrictMode  bool
	Branch            string  // branch name provided in the header
	TXN               *sql.Tx // transaction for MySQL
	SQLServerTXN      *sql.Tx // Transaction for SQLServer
	GraphDbTXN        *dgo.Txn
	// contains filtered or unexported fields
}

AbstractBusinessLogicHolder use this type to inheritance

func (*AbstractBusinessLogicHolder) EchoBL

func (ab *AbstractBusinessLogicHolder) EchoBL() (map[string]interface{}, error)

EchoBL sample EchoBL logic handler

func (*AbstractBusinessLogicHolder) FetchValues

func (ab *AbstractBusinessLogicHolder) FetchValues(keyName, query string) (gjson.Result, int, error)

FetchValues -FetchValues

func (*AbstractBusinessLogicHolder) GetAbLocalServiceData

func (ab *AbstractBusinessLogicHolder) GetAbLocalServiceData() map[string]interface{}

GetAllAbsData - GetAllAbsData

func (*AbstractBusinessLogicHolder) GetClientIP

func (ab *AbstractBusinessLogicHolder) GetClientIP() string

GetClientIP will returns client ip address

func (*AbstractBusinessLogicHolder) GetCustomData

func (ab *AbstractBusinessLogicHolder) GetCustomData(key string) (interface{}, bool)

GetCustomData will give you string

func (*AbstractBusinessLogicHolder) GetDataBool

func (ab *AbstractBusinessLogicHolder) GetDataBool(key string) (bool, bool)

GetDataBool will give you int

func (*AbstractBusinessLogicHolder) GetDataInt

func (ab *AbstractBusinessLogicHolder) GetDataInt(key string) (int64, bool)

GetDataInt will give you int

func (*AbstractBusinessLogicHolder) GetDataInterface

func (ab *AbstractBusinessLogicHolder) GetDataInterface(key string) (interface{}, bool)

GetDataInterface will give you int

func (*AbstractBusinessLogicHolder) GetDataResultset

func (ab *AbstractBusinessLogicHolder) GetDataResultset(key string) (*gjson.Result, bool)

GetDataResultset will give you int

func (*AbstractBusinessLogicHolder) GetDataString

func (ab *AbstractBusinessLogicHolder) GetDataString(key string) (string, bool)

GetDataString will give you string

func (*AbstractBusinessLogicHolder) GetErrorCode

func (ab *AbstractBusinessLogicHolder) GetErrorCode() int

GetErrorCode - GetErrorCode in service context

func (*AbstractBusinessLogicHolder) GetErrorData

func (ab *AbstractBusinessLogicHolder) GetErrorData() interface{}

GetErrorData - GetErrorData in service context

func (*AbstractBusinessLogicHolder) GetFinalData

func (ab *AbstractBusinessLogicHolder) GetFinalData() *interface{}

GetFinalData will return map data with finaldata key

func (*AbstractBusinessLogicHolder) GetGlobalConfigString

func (ab *AbstractBusinessLogicHolder) GetGlobalConfigString(key string) (string, bool)

GetGlobalConfigString - return string value for global config key

func (*AbstractBusinessLogicHolder) GetMQLRequestData

func (ab *AbstractBusinessLogicHolder) GetMQLRequestData() (*gjson.Result, bool)

GetMQLRequestData - returns MQLRequestData

func (*AbstractBusinessLogicHolder) GetPrincipalObject

func (ab *AbstractBusinessLogicHolder) GetPrincipalObject() *Principal

GetPrincipalObject - return Principal object from BLHolder

func (*AbstractBusinessLogicHolder) GetResposeObject

func (ab *AbstractBusinessLogicHolder) GetResposeObject(responseKey string) (*APIResponse, error)

GetResposeObject - return Response object from BLHolder

func (*AbstractBusinessLogicHolder) GetServerIP

func (ab *AbstractBusinessLogicHolder) GetServerIP() string

GetServerIP will returns server ip address

func (*AbstractBusinessLogicHolder) New

New will create memory for your data

func (*AbstractBusinessLogicHolder) SetBranch

func (ab *AbstractBusinessLogicHolder) SetBranch(branch string)

func (*AbstractBusinessLogicHolder) SetByteData

func (ab *AbstractBusinessLogicHolder) SetByteData(key string, obj []byte)

SetByteData will set byte data as gjson.Result

func (*AbstractBusinessLogicHolder) SetCustomData

func (ab *AbstractBusinessLogicHolder) SetCustomData(key string, data interface{})

SetCustomData set custom user data in map

func (*AbstractBusinessLogicHolder) SetErrorCode

func (ab *AbstractBusinessLogicHolder) SetErrorCode(code int)

SetErrorCode - SetErrorCode in service context

func (*AbstractBusinessLogicHolder) SetErrorData

func (ab *AbstractBusinessLogicHolder) SetErrorData(data interface{})

SetErrorData will set error

func (*AbstractBusinessLogicHolder) SetFinalData

func (ab *AbstractBusinessLogicHolder) SetFinalData(data interface{})

SetFinalData will return map data with finaldata key

func (*AbstractBusinessLogicHolder) SetMQLRequestData

func (ab *AbstractBusinessLogicHolder) SetMQLRequestData(obj *gjson.Result)

SetMQLRequestData - set value

func (*AbstractBusinessLogicHolder) SetMQLToken

func (ab *AbstractBusinessLogicHolder) SetMQLToken(token string)

SetMQLToken will set token in header

func (*AbstractBusinessLogicHolder) SetResultset

func (ab *AbstractBusinessLogicHolder) SetResultset(key string, obj *gjson.Result)

SetResultset will return map data with finaldata key

type DebugInfo

type DebugInfo struct {
	StackTrace      strings.Builder `json:"stackTrace"`
	PerformanceInfo strings.Builder `json:"performanceInfo"`
}

DebugInfo - DebugInfo

type FinalStepProcessOutput

type FinalStepProcessOutput = func(ab *AbstractBusinessLogicHolder) (*interface{}, error)

FinalStepProcessOutput is a method sign for loader methods

type GlobalConfigModel

type GlobalConfigModel struct {
	Key          string   `json:"key"`
	Value        string   `json:"value"`
	Restrictions []string `json:"restrictions"`
}

GlobalConfigModel - GlobalConfigModel

type Header struct {
	Key   string
	Value []string
}

type LoadData

type LoadData = func(ab *AbstractBusinessLogicHolder) error

LoadData is a method sign for loader methods

type Principal

type Principal struct {
	UserID            string    `json:"userId"`
	Groups            []string  `json:"groups"`
	SessionExpiration time.Time `json:"sessionExpiration"`
	ClientIP          string    `json:"clientIP"`
	HitsCount         int       `json:"hitsCount"`
	Token             string    `json:"token"`
	Metadata          string    `json:"metadata"`
}

Principal - Object inside JWT token

type ServiceBuilder

type ServiceBuilder struct {
	ServiceName string

	ServiceError error
	// contains filtered or unexported fields
}

ServiceBuilder will help you to run steps

func GetSB

GetSB Gives you service builder from where you can run steps

func (*ServiceBuilder) AddStep

func (sb *ServiceBuilder) AddStep(stepname, rule string, ld LoadData, blfunc, errorfunc func() (map[string]interface{}, error)) *ServiceBuilder

AddStep will add func step with rule Stepname : Give Name to step. It will appear in log. Rule : Give Ybl rule blfunc : Give Business Logic function pointer errorfunc : Give Error function pointer

func (*ServiceBuilder) AddStepWithGoTo

func (sb *ServiceBuilder) AddStepWithGoTo(stepname, rule string, ld LoadData, blfunc, errorfunc func() (map[string]interface{}, error), gotoStepName string) *ServiceBuilder

AddStepWithGoTo - AddStep with goto pointer

func (*ServiceBuilder) AddValidation

func (sb *ServiceBuilder) AddValidation(dataKey string, validationfunc func(interface{}) error) *ServiceBuilder

AddValidation add validation step for give dataKey

func (*ServiceBuilder) Run

func (sb *ServiceBuilder) Run(fn FinalStepProcessOutput) (*interface{}, error)

Run all Steps one by one

type Step

type Step struct {
	Stepname string

	IsValidator       bool
	ValidationDataKey string
	ValidationFunc    func(interface{}) error
	RunFunc           func() (map[string]interface{}, error)
	ErrorFunc         func() (map[string]interface{}, error)
	JumpStep          string
	// contains filtered or unexported fields
}

Step help to maintain steps

Jump to

Keyboard shortcuts

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