handlers

package
v0.4.0-beta Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRequest = errors.New("invalid request for context")
	ErrSessionMissing = errors.New("missing session")
	ErrInvalidInput   = errors.New("invalid input")
	ErrStorage        = errors.New("storage retrieval fail")
	ErrEngineType     = errors.New("incompatible engine")
	ErrEngineInit     = errors.New("engine init fail")
	ErrEngineExec     = errors.New("engine exec fail")
)

Functions

This section is empty.

Types

type BaseSessionHandler

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

func NewBaseSessionHandler

func NewBaseSessionHandler(cfg engine.Config, rs resource.Resource, stateDb db.Db, userdataDb db.Db, rp RequestParser, hn *ussd.Handlers) *BaseSessionHandler

func (*BaseSessionHandler) GetConfig

func (f *BaseSessionHandler) GetConfig() engine.Config

func (*BaseSessionHandler) GetEngine

func (*BaseSessionHandler) GetRequestParser

func (f *BaseSessionHandler) GetRequestParser() RequestParser

func (*BaseSessionHandler) Output

func (*BaseSessionHandler) Process

func (*BaseSessionHandler) Reset

func (*BaseSessionHandler) Shutdown

func (f *BaseSessionHandler) Shutdown()

type HandlerService

type HandlerService interface {
	GetHandler() (*ussd.Handlers, error)
}

type LocalHandlerService

type LocalHandlerService struct {
	Parser        *asm.FlagParser
	DbRs          *resource.DbResource
	Pe            *persist.Persister
	UserdataStore *db.Db
	AdminStore    *utils.AdminStore
	Cfg           engine.Config
	Rs            resource.Resource
}

func NewLocalHandlerService

func NewLocalHandlerService(ctx context.Context, fp string, debug bool, dbResource *resource.DbResource, cfg engine.Config, rs resource.Resource) (*LocalHandlerService, error)

func (*LocalHandlerService) GetEngine

func (ls *LocalHandlerService) GetEngine() *engine.DefaultEngine

TODO: enable setting of sessionId on engine init time

func (*LocalHandlerService) GetHandler

func (ls *LocalHandlerService) GetHandler(accountService remote.AccountServiceInterface) (*ussd.Handlers, error)

func (*LocalHandlerService) SetDataStore

func (ls *LocalHandlerService) SetDataStore(db *db.Db)

func (*LocalHandlerService) SetPersister

func (ls *LocalHandlerService) SetPersister(Pe *persist.Persister)

type RequestHandler

type RequestHandler interface {
	GetConfig() engine.Config
	GetRequestParser() RequestParser
	GetEngine(cfg engine.Config, rs resource.Resource, pe *persist.Persister) engine.Engine
	Process(rs RequestSession) (RequestSession, error)
	Output(rs RequestSession) (RequestSession, error)
	Reset(rs RequestSession) (RequestSession, error)
	Shutdown()
}

type RequestParser

type RequestParser interface {
	GetSessionId(rq any) (string, error)
	GetInput(rq any) ([]byte, error)
}

TODO: seems like can remove this.

type RequestSession

type RequestSession struct {
	Ctx      context.Context
	Config   engine.Config
	Engine   engine.Engine
	Input    []byte
	Storage  *storage.Storage
	Writer   io.Writer
	Continue bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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