interfaces

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event interface {
	Topic() string
	Message() *Message
	Ack() error
	Error() error
}

type IBroker

type IBroker interface {
	Init(app IService) error
	Stop() error
	String() string

	Publish(topic string, m *Message) error
	Subscribe(topic string, s *Subscriber) error
}

type ICache

type ICache interface {
	Init(app IService) error
	Stop() error
	String() string

	Has(key string) bool
	Set(key string, args any, timeout time.Duration) error
	Get(key string) (any, error)
	Delete(key string) error
}

type IConfig

type IConfig interface {
	Init(app IService) error
	Stop() error
	Has(key string) bool
	GetString(key string, def string) string
	GetBool(key string, def bool) bool
	GetInt(key string, def int) int
	GetFloat(key string, def float32) float32
}

type IController

type IController interface {
	Init(app IService) error
	Stop() error
	String() string
}

type IDatabase

type IDatabase interface {
	Init(app IService) error
	Stop() error
	String() string

	Query(ctx context.Context, query string, args ...interface{}) (SQLRows, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) (SQLRow, error)
	Exec(ctx context.Context, query string, args ...interface{}) error
	GetDb() interface{}
}

type ILogger

type ILogger interface {
	Init(app IService) error
	Stop() error
	SetLevel(level LogLevel)
	Push(level LogLevel, msg string, toParent bool)
	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Message(args ...interface{})
	Error(err error)
	Fatal(err error)
	Panic(err error)
}

type IModules

type IModules interface {
	Init(app IService) error
	Stop() error
	String() string
}

type INoSql added in v0.0.5

type INoSql interface {
	Init(app IService) error
	Stop() error
	String() string

	Count(ctx context.Context, key interface{}, query interface{}, args ...interface{}) int64
	Exists(ctx context.Context, key interface{}, query interface{}, args ...interface{}) bool
	Insert(ctx context.Context, key interface{}, query interface{}, args ...interface{}) (interface{}, error)
	FindOne(ctx context.Context, key interface{}, query interface{}, args ...interface{}) (NoSQLRow, error)
	Find(ctx context.Context, key interface{}, query interface{}, args ...interface{}) (NoSQLRows, error)
	Exec(ctx context.Context, key interface{}, query interface{}, args ...interface{}) (NoSQLRows, error)
	Update(ctx context.Context, key interface{}, query interface{}, args ...interface{}) error
	Delete(ctx context.Context, key interface{}, query interface{}, args ...interface{}) int64
	Batch(ctx context.Context, key interface{}, query interface{}, typeOp string, args ...interface{}) (int64, error)
	GetDb() interface{}
}

type IRepository

type IRepository interface {
	Init(app IService) error
	Stop() error
	String() string
}

type IServer

type IServer interface {
	Init(app IService) error
	Start() error
	Stop() error
	String() string
	PushRoute(method string, path string, handler RouteFunc)
}

type IService

type IService interface {
	Init() error
	Stop() error
	GetLogger() ILogger
	GetConfig() IConfig
	PushCache(c ICache) IService
	GetCache(key string) ICache
	PushBroker(c IBroker) IService
	GetBroker(key string) IBroker
	PushDatabase(c IDatabase) IService
	GetDatabase(key string) IDatabase
	PushController(c IController) IService
	GetController(key string) IController
	PushModule(c IModules) IService
	GetModule(key string) IModules
	PushRepository(c IRepository) IService
	GetRepository(key string) IRepository
	PushServer(c IServer) IService
	GetServer(key string) IServer
	PushStorage(c IStorage) IService
	GetStorage(key string) IStorage
}

type IStorage

type IStorage interface {
	Init(app IService) error
	Stop() error
	String() string

	Has(name string) bool
	Put(name string, data []byte) error
	Read(name string) ([]byte, error)
	Delete(name string) error
	List() []string
}

type LogLevel

type LogLevel int
const (
	DEBUG LogLevel = iota
	INFO
	WARNING
	MESSAGE
	ERROR
	CRITICAL
)

func GetLogLevel

func GetLogLevel(str string) LogLevel

func (LogLevel) String

func (t LogLevel) String() string

type Message

type Message struct {
	Header map[string]string
	Body   []byte
}

type NoSQLRow added in v0.0.6

type NoSQLRow interface {
	Scan(dest any) error
}

type NoSQLRows added in v0.0.6

type NoSQLRows interface {
	Next() bool
	Scan(dest any) error
	Close() error
}

type RouteFunc added in v0.0.2

type RouteFunc func(ctx *srvCtx.Ctx)

type SQLRow added in v0.0.6

type SQLRow interface {
	Scan(dest ...any) error
}

type SQLRows added in v0.0.6

type SQLRows interface {
	Next() bool
	Scan(dest ...any) error
	Close() error
}

type Subscriber

type Subscriber interface {
	Handler(event *Event) error
	Unsubscribe() error
}

Jump to

Keyboard shortcuts

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