Documentation
¶
Index ¶
- Constants
- func ConvertAssign(dest, src interface{}) error
- func HandleBusMiddleware(worker Worker)
- func InSlice(array interface{}, item interface{}) bool
- func NewMap(dst interface{}) error
- func NewSlice(dsc interface{}, len int) error
- func Prepare(f func(Initiator))
- func SliceDelete(arr interface{}, indexArr ...int) error
- type Application
- func (app *Application) AsyncCachePreheat(f func(repo *Repository))
- func (app *Application) BindController(relativePath string, controller interface{}, handlers ...context.Handler)
- func (app *Application) BindControllerByParty(party iris.Party, controller interface{})
- func (app *Application) BindFactory(f interface{})
- func (app *Application) BindInfra(single bool, com interface{})
- func (app *Application) BindRepository(f interface{})
- func (app *Application) BindService(f interface{})
- func (app *Application) CachePreheat(f func(repo *Repository))
- func (app *Application) CallService(fun interface{}, worker ...Worker)
- func (app *Application) CreateParty(relativePath string, handlers ...context.Handler) iris.Party
- func (app *Application) CreateRunner(addr string, configurators ...host.Configurator) iris.Runner
- func (app *Application) EventsPath(infra interface{}) map[string]string
- func (app *Application) GetInfra(ctx iris.Context, com interface{})
- func (app *Application) GetService(ctx iris.Context, service interface{})
- func (app *Application) GetSingleInfra(com interface{}) bool
- func (app *Application) InjectController(f interface{})
- func (app *Application) InstallBusMiddleware(handle ...BusHandler)
- func (app *Application) InstallDB(f func() interface{})
- func (app *Application) InstallMiddleware(handler iris.Handler)
- func (app *Application) InstallOther(f func() interface{})
- func (app *Application) InstallParty(relativePath string)
- func (app *Application) InstallRedis(f func() (client redis.Cmdable))
- func (app *Application) InstallSerializer(marshal func(v interface{}) ([]byte, error), ...)
- func (app *Application) Iris() *iris.Application
- func (app *Application) ListenEvent(eventName string, objectMethod string, appointInfra ...interface{})
- func (app *Application) Logger() *golog.Logger
- func (app *Application) NewAutoTLSRunner(addr string, domain string, email string, configurators ...host.Configurator) iris.Runner
- func (app *Application) NewH2CRunner(addr string, configurators ...host.Configurator) iris.Runner
- func (app *Application) NewRunner(addr string, configurators ...host.Configurator) iris.Runner
- func (app *Application) NewTLSRunner(addr string, certFile, keyFile string, configurators ...host.Configurator) iris.Runner
- func (app *Application) RegisterShutdown(f func())
- func (app *Application) Run(serve iris.Runner, irisConf iris.Configuration)
- func (app *Application) Start(f func(starter Starter))
- type BeginRequest
- type Bus
- type BusHandler
- type DomainEvent
- type Entity
- type EventBus
- type FactoryPool
- type Infra
- func (infra *Infra) BeginRequest(rt Worker)
- func (infra *Infra) GetSingleInfra(com interface{}) bool
- func (infra *Infra) GetWorker() Worker
- func (infra *Infra) InjectBaseEntity(entity Entity)
- func (infra *Infra) InjectBaseEntitys(entitys interface{})
- func (infra *Infra) NewH2CRequest(url string, transferBus ...bool) requests.Request
- func (infra *Infra) NewHTTPRequest(url string, transferBus ...bool) requests.Request
- func (infra *Infra) Other(obj interface{})
- func (infra *Infra) Redis() redis.Cmdable
- func (infra *Infra) SourceDB() (db interface{})
- type InfraPool
- type Initiator
- type JMap
- func (jm *JMap) AllKey() []interface{}
- func (jm *JMap) DelAll()
- func (jm *JMap) Exist(key interface{}) bool
- func (jm *JMap) Get(key interface{}, value interface{}) error
- func (jm *JMap) Interface(key interface{}) interface{}
- func (jm *JMap) Remove(key interface{})
- func (jm *JMap) Set(key interface{}, value interface{})
- func (jm *JMap) SetOrStore(key interface{}, value interface{}) (v interface{}, set bool)
- type Logger
- type Prometheus
- type Repository
- func (repo *Repository) BeginRequest(rt Worker)
- func (repo *Repository) FetchDB(db interface{}) error
- func (repo *Repository) FetchSourceDB(db interface{}) error
- func (repo *Repository) GetWorker() Worker
- func (repo *Repository) InjectBaseEntity(entity Entity)
- func (repo *Repository) InjectBaseEntitys(entitys interface{})
- func (repo *Repository) NewH2CRequest(url string, transferBus ...bool) requests.Request
- func (repo *Repository) NewHTTPRequest(url string, transferBus ...bool) requests.Request
- func (repo *Repository) Other(obj interface{})
- func (repo *Repository) Redis() redis.Cmdable
- type RepositoryPool
- type Scanner
- type ServicePool
- type SingleBoot
- type Starter
- type Store
- func (s *Store) Exist(key interface{}) bool
- func (s *Store) Get(key interface{}, value interface{}) error
- func (s *Store) Keys() []interface{}
- func (s *Store) Remove(key interface{})
- func (s *Store) RemoveAll()
- func (s *Store) Set(key interface{}, value interface{})
- func (s *Store) SetOrStore(key interface{}, value interface{}) (v interface{}, set bool)
- func (s *Store) ToInterface(key interface{}) interface{}
- func (s *Store) ToMap() map[interface{}]interface{}
- func (s *Store) Values() []interface{}
- type UnitTest
- type UnitTestImpl
- func (u *UnitTestImpl) GetFactory(factory interface{})
- func (u *UnitTestImpl) GetRepository(repository interface{})
- func (u *UnitTestImpl) GetService(service interface{})
- func (u *UnitTestImpl) InjectBaseEntity(entity interface{})
- func (u *UnitTestImpl) InstallDB(f func() (db interface{}))
- func (u *UnitTestImpl) InstallRedis(f func() (client redis.Cmdable))
- func (u *UnitTestImpl) Run()
- func (u *UnitTestImpl) SetRequest(request *http.Request)
- type Worker
Constants ¶
const (
//WorkerKey .
WorkerKey = "STORE-WORKER-KEY"
)
Variables ¶
This section is empty.
Functions ¶
func Prepare ¶
func Prepare(f func(Initiator))
Prepare app.BindController or app.BindControllerByParty.
func SliceDelete ¶
SliceDelete delete the specified subscript element of the array
Types ¶
type Application ¶
type Application struct {
// IrisApp is an iris application
IrisApp *iris.Application
// Database contains a database connection object and an installation function
Database struct {
Install func() (db interface{})
// contains filtered or unexported fields
}
// Cache contains a redis client and an installation function
Cache struct {
Install func() (client redis.Cmdable)
// contains filtered or unexported fields
}
// Middleware is a set that satisfies the iris handler's definition
Middleware []context.Handler
Prometheus *Prometheus
// ControllerDep TODO
ControllerDep []interface{}
// contains filtered or unexported fields
}
Application is the framework's application. Create an application of freedom, by using NewApplication().
func NewApplication ¶
func NewApplication() *Application
NewApplication create an instance of freedom.
func (*Application) AsyncCachePreheat ¶
func (app *Application) AsyncCachePreheat(f func(repo *Repository))
AsyncCachePreheat .
func (*Application) BindController ¶
func (app *Application) BindController(relativePath string, controller interface{}, handlers ...context.Handler)
BindController binds the controller that satisfies the iris's definition to the Application and adds the controller into msgsBus
func (*Application) BindControllerByParty ¶
func (app *Application) BindControllerByParty(party iris.Party, controller interface{})
BindControllerByParty binds the controller by iris's party
func (*Application) BindFactory ¶ added in v1.7.11
func (app *Application) BindFactory(f interface{})
BindFactory .
func (*Application) BindInfra ¶
func (app *Application) BindInfra(single bool, com interface{})
BindInfra .
func (*Application) BindRepository ¶
func (app *Application) BindRepository(f interface{})
BindRepository .
func (*Application) CachePreheat ¶
func (app *Application) CachePreheat(f func(repo *Repository))
CachePreheat .
func (*Application) CallService ¶ added in v1.7.16
func (app *Application) CallService(fun interface{}, worker ...Worker)
CallService .
func (*Application) CreateParty ¶
CreateParty returns a sub-router of iris which may have the same prefix and share same handlers
func (*Application) CreateRunner ¶
func (app *Application) CreateRunner(addr string, configurators ...host.Configurator) iris.Runner
CreateRunner become invalid after a specified date.
func (*Application) EventsPath ¶
func (app *Application) EventsPath(infra interface{}) map[string]string
EventsPath .
func (*Application) GetInfra ¶
func (app *Application) GetInfra(ctx iris.Context, com interface{})
GetInfra .
func (*Application) GetService ¶
func (app *Application) GetService(ctx iris.Context, service interface{})
GetService TODO
func (*Application) GetSingleInfra ¶
func (app *Application) GetSingleInfra(com interface{}) bool
GetSingleInfra .
func (*Application) InjectController ¶
func (app *Application) InjectController(f interface{})
InjectController .
func (*Application) InstallBusMiddleware ¶
func (app *Application) InstallBusMiddleware(handle ...BusHandler)
InstallBusMiddleware .
func (*Application) InstallDB ¶ added in v1.7.13
func (app *Application) InstallDB(f func() interface{})
InstallDB .
func (*Application) InstallMiddleware ¶
func (app *Application) InstallMiddleware(handler iris.Handler)
InstallMiddleware .
func (*Application) InstallOther ¶
func (app *Application) InstallOther(f func() interface{})
InstallOther .
func (*Application) InstallParty ¶
func (app *Application) InstallParty(relativePath string)
InstallParty installs prefixParty of Application
func (*Application) InstallRedis ¶
func (app *Application) InstallRedis(f func() (client redis.Cmdable))
InstallRedis .
func (*Application) InstallSerializer ¶
func (app *Application) InstallSerializer(marshal func(v interface{}) ([]byte, error), unmarshal func(data []byte, v interface{}) error)
InstallSerializer .
func (*Application) ListenEvent ¶
func (app *Application) ListenEvent(eventName string, objectMethod string, appointInfra ...interface{})
ListenEvent .
func (*Application) NewAutoTLSRunner ¶ added in v1.8.5
func (app *Application) NewAutoTLSRunner(addr string, domain string, email string, configurators ...host.Configurator) iris.Runner
NewAutoTLSRunner can be used as an argument for the `Run` method. It will start the Application's secure server using certifications created on the fly by the "autocert" golang/x package, so localhost may not be working, use it at "production" machine.
Addr should have the form of host:port, i.e mydomain.com:443.
The whitelisted domains are separated by whitespace in "domain" argument, i.e "8tree.net", can be different than "addr". If empty, all hosts are currently allowed. This is not recommended, as it opens a potential attack where clients connect to a server by IP address and pretend to be asking for an incorrect host name. Manager will attempt to obtain a certificate for that host, incorrectly, eventually reaching the CA's rate limit for certificate requests and making it impossible to obtain actual certificates.
For an "e-mail" use a non-public one, letsencrypt needs that for your own security.
Note: `AutoTLS` will start a new server for you which will redirect all http versions to their https, including subdomains as well.
Last argument is optional, it accepts one or more `func(*host.Configurator)` that are being executed on that specific host that this function will create to start the server. Via host configurators you can configure the back-end host supervisor, i.e to add events for shutdown, serve or error. Look at the `ConfigureHost` too.
func (*Application) NewH2CRunner ¶ added in v1.8.5
func (app *Application) NewH2CRunner(addr string, configurators ...host.Configurator) iris.Runner
NewH2CRunner .
func (*Application) NewRunner ¶ added in v1.8.5
func (app *Application) NewRunner(addr string, configurators ...host.Configurator) iris.Runner
NewRunner can be used as an argument for the `Run` method. It accepts a host address which is used to build a server and a listener which listens on that host and port.
Addr should have the form of host:port, i.e localhost:8080 or :8080.
Second argument is optional, it accepts one or more `func(*host.Configurator)` that are being executed on that specific host that this function will create to start the server. Via host configurators you can configure the back-end host supervisor, i.e to add events for shutdown, serve or error.
func (*Application) NewTLSRunner ¶ added in v1.8.5
func (app *Application) NewTLSRunner(addr string, certFile, keyFile string, configurators ...host.Configurator) iris.Runner
NewTLSRunner can be used as an argument for the `Run` method. It will start the Application's secure server.
Use it like you used to use the http.ListenAndServeTLS function.
Addr should have the form of host:port, i.e localhost:443 or :443. CertFile & KeyFile should be filenames with their extensions.
Second argument is optional, it accepts one or more `func(*host.Configurator)` that are being executed on that specific host that this function will create to start the server. Via host configurators you can configure the back-end host supervisor, i.e to add events for shutdown, serve or error. An example of this use case can be found at:
func (*Application) RegisterShutdown ¶ added in v1.8.0
func (app *Application) RegisterShutdown(f func())
RegisterShutdown .
func (*Application) Run ¶
func (app *Application) Run(serve iris.Runner, irisConf iris.Configuration)
Run .
type DomainEvent ¶ added in v1.8.6
type DomainEvent interface {
Topic() string
SetPrototypes(map[string]interface{})
GetPrototypes() map[string]interface{}
Marshal() []byte
Identity() interface{}
SetIdentity(identity interface{})
}
DomainEvent .
type Entity ¶
type Entity interface {
Identity() string
GetWorker() Worker
Marshal() []byte
AddPubEvent(DomainEvent)
GetPubEvent() []DomainEvent
RemoveAllPubEvent()
AddSubEvent(DomainEvent)
GetSubEvent() []DomainEvent
RemoveAllSubEvent()
}
Entity is the entity's father interface.
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus .
func (*EventBus) EventsPath ¶
EventsPath .
type FactoryPool ¶ added in v1.7.11
type FactoryPool struct {
// contains filtered or unexported fields
}
FactoryPool .
type Infra ¶
type Infra struct {
Worker Worker `json:"-"`
}
Infra .
func (*Infra) GetSingleInfra ¶ added in v1.8.6
GetSingleInfra .
func (*Infra) InjectBaseEntity ¶ added in v1.7.5
InjectBaseEntity .
func (*Infra) InjectBaseEntitys ¶ added in v1.7.5
func (infra *Infra) InjectBaseEntitys(entitys interface{})
InjectBaseEntitys .
func (*Infra) NewH2CRequest ¶
NewH2CRequest transferBus : Whether to pass the context, turned on by default. Typically used for tracking internal services.
func (*Infra) NewHTTPRequest ¶ added in v1.8.0
NewHTTPRequest transferBus : Whether to pass the context, turned on by default. Typically used for tracking internal services.
type Initiator ¶
type Initiator interface {
CreateParty(relativePath string, handlers ...context.Handler) iris.Party
BindController(relativePath string, controller interface{}, handlers ...context.Handler)
BindControllerByParty(party iris.Party, controller interface{})
BindService(f interface{})
InjectController(f interface{})
BindRepository(f interface{})
BindFactory(f interface{})
GetService(ctx iris.Context, service interface{})
// BindInfra if is a singleton, com is an object. if is multiton, com is a function
BindInfra(single bool, com interface{})
GetInfra(ctx iris.Context, com interface{})
// Listen Event
ListenEvent(eventName string, objectMethod string, appointInfra ...interface{})
Start(f func(starter Starter))
Iris() *iris.Application
}
Initiator .
type JMap ¶
type JMap struct {
// contains filtered or unexported fields
}
JMap .
func (*JMap) SetOrStore ¶
SetOrStore .
type Logger ¶
type Logger interface {
Print(v ...interface{})
Println(v ...interface{})
Fatal(v ...interface{})
Fatalf(format string, args ...interface{})
Error(v ...interface{})
Errorf(format string, args ...interface{})
Warn(v ...interface{})
Warnf(format string, args ...interface{})
Info(v ...interface{})
Infof(format string, args ...interface{})
Debug(v ...interface{})
Debugf(format string, args ...interface{})
}
Logger .
type Prometheus ¶
type Prometheus struct {
// contains filtered or unexported fields
}
Prometheus is a handler that exposes prometheus metrics for the number of requests, the latency and the response size, partitioned by status code, method and HTTP path.
Usage: pass its `ServeHTTP` to a route or globally.
func (*Prometheus) OrmWithLabelValues ¶
func (p *Prometheus) OrmWithLabelValues(model, method string, e error, starTime time.Time)
OrmWithLabelValues .
func (*Prometheus) RegisterCounter ¶
func (p *Prometheus) RegisterCounter(conter *prometheus.CounterVec)
RegisterCounter .
func (*Prometheus) RegisterHistogram ¶
func (p *Prometheus) RegisterHistogram(histogram *prometheus.HistogramVec)
RegisterHistogram .
type Repository ¶
type Repository struct {
Worker Worker
}
Repository .
func (*Repository) FetchDB ¶ added in v1.7.13
func (repo *Repository) FetchDB(db interface{}) error
FetchDB .
func (*Repository) FetchSourceDB ¶ added in v1.7.13
func (repo *Repository) FetchSourceDB(db interface{}) error
FetchSourceDB .
func (*Repository) InjectBaseEntity ¶
func (repo *Repository) InjectBaseEntity(entity Entity)
InjectBaseEntity .
func (*Repository) InjectBaseEntitys ¶
func (repo *Repository) InjectBaseEntitys(entitys interface{})
InjectBaseEntitys .
func (*Repository) NewH2CRequest ¶
func (repo *Repository) NewH2CRequest(url string, transferBus ...bool) requests.Request
NewH2CRequest transferBus : Whether to pass the context, turned on by default. Typically used for tracking internal services.
func (*Repository) NewHTTPRequest ¶ added in v1.8.0
func (repo *Repository) NewHTTPRequest(url string, transferBus ...bool) requests.Request
NewHTTPRequest transferBus : Whether to pass the context, turned on by default. Typically used for tracking internal services.
type RepositoryPool ¶
type RepositoryPool struct {
// contains filtered or unexported fields
}
RepositoryPool .
type ServicePool ¶
type ServicePool struct {
// contains filtered or unexported fields
}
ServicePool is domain service pool,a domain service type owns a pool instancePool key: the reflect.Type of domain service instancePool value: *sync.Pool
type SingleBoot ¶
type SingleBoot interface {
Iris() *iris.Application
//Pass in the current component to get the event path, which can bind the specified component.
EventsPath(infra interface{}) map[string]string
//Register for a shutdown event.
RegisterShutdown(func())
}
SingleBoot singleton startup component.
type Starter ¶
type Starter interface {
Iris() *iris.Application
// Asynchronous cache warm-up
AsyncCachePreheat(f func(repo *Repository))
// Sync cache warm-up
CachePreheat(f func(repo *Repository))
GetSingleInfra(com interface{}) bool
}
Starter .
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store .
func (*Store) SetOrStore ¶
SetOrStore .
type UnitTest ¶
type UnitTest interface {
GetService(service interface{})
GetRepository(repository interface{})
GetFactory(factory interface{})
InstallDB(f func() (db interface{}))
InstallRedis(f func() (client redis.Cmdable))
Run()
SetRequest(request *http.Request)
InjectBaseEntity(entity interface{})
}
UnitTest .
type UnitTestImpl ¶
type UnitTestImpl struct {
// contains filtered or unexported fields
}
UnitTestImpl .
func (*UnitTestImpl) GetFactory ¶ added in v1.7.12
func (u *UnitTestImpl) GetFactory(factory interface{})
GetFactory .
func (*UnitTestImpl) GetRepository ¶
func (u *UnitTestImpl) GetRepository(repository interface{})
GetRepository .
func (*UnitTestImpl) GetService ¶
func (u *UnitTestImpl) GetService(service interface{})
GetService .
func (*UnitTestImpl) InjectBaseEntity ¶
func (u *UnitTestImpl) InjectBaseEntity(entity interface{})
InjectBaseEntity .
func (*UnitTestImpl) InstallDB ¶ added in v1.7.13
func (u *UnitTestImpl) InstallDB(f func() (db interface{}))
InstallDB .
func (*UnitTestImpl) InstallRedis ¶
func (u *UnitTestImpl) InstallRedis(f func() (client redis.Cmdable))
InstallRedis .
func (*UnitTestImpl) SetRequest ¶
func (u *UnitTestImpl) SetRequest(request *http.Request)
SetRequest .