general

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuntimeKey = "runtime-ctx"
)

Variables

This section is empty.

Functions

func Booting

func Booting(f func(Initiator))

Booting app.BindController or app.BindControllerByParty.

func ConvertAssign

func ConvertAssign(dest, src interface{}) error

func InSlice

func InSlice(array interface{}, item interface{}) bool

InSlice 是否在数组内

func NewMap added in v1.1.9

func NewMap(dst interface{}) error

NewMap

Types

type Application

type Application struct {
	IrisApp *iris.Application

	Database struct {
		Install func() (db *gorm.DB)
		// contains filtered or unexported fields
	}

	Cache struct {
		Install func() (client redis.Cmdable)
		// contains filtered or unexported fields
	}
	Middleware    []context.Handler
	Prometheus    *Prometheus
	ControllerDep []interface{}
	// contains filtered or unexported fields
}

Application .

func NewApplication

func NewApplication() *Application

NewApplication .

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 .

func (*Application) BindControllerByParty

func (app *Application) BindControllerByParty(party iris.Party, controller interface{})

BindControllerByParty .

func (*Application) BindInfra added in v1.3.0

func (app *Application) BindInfra(single bool, com interface{})

BindInfra .

func (*Application) BindRepository

func (app *Application) BindRepository(f interface{})

BindRepository .

func (*Application) BindService

func (app *Application) BindService(f interface{})

BindService .

func (*Application) CachePreheat

func (app *Application) CachePreheat(f func(repo *Repository))

CachePreheat .

func (*Application) Closeing added in v1.5.0

func (app *Application) Closeing(f func())

Register .

func (*Application) CreateH2CRunner added in v1.0.5

func (app *Application) CreateH2CRunner(addr string, configurators ...host.Configurator) iris.Runner

func (*Application) CreateParty

func (app *Application) CreateParty(relativePath string, handlers ...context.Handler) iris.Party

CreateParty .

func (*Application) CreateRunner added in v1.5.0

func (app *Application) CreateRunner(addr string, configurators ...host.Configurator) iris.Runner

func (*Application) EventsPath added in v1.3.0

func (app *Application) EventsPath(infra interface{}) map[string]string

EventsPath .

func (*Application) GetInfra added in v1.3.0

func (app *Application) GetInfra(ctx iris.Context, com interface{})

GetInfra .

func (*Application) GetService

func (app *Application) GetService(ctx iris.Context, service interface{})

GetService .

func (*Application) InjectController added in v1.1.0

func (app *Application) InjectController(f interface{})

InjectController .

func (*Application) InstallDomainEventInfra added in v1.3.7

func (app *Application) InstallDomainEventInfra(eventInfra DomainEventInfra)

InstallDomainEventInfra .

func (*Application) InstallGorm added in v1.0.5

func (app *Application) InstallGorm(f func() (db *gorm.DB))

InstallGorm .

func (*Application) InstallMiddleware added in v1.0.5

func (app *Application) InstallMiddleware(handler iris.Handler)

InstallMiddleware .

func (*Application) InstallParty added in v1.2.1

func (app *Application) InstallParty(relativePath string)

InstallParty .

func (*Application) InstallRedis added in v1.0.5

func (app *Application) InstallRedis(f func() (client redis.Cmdable))

InstallRedis .

func (*Application) Iris added in v1.0.5

func (app *Application) Iris() *iris.Application

Iris .

func (*Application) ListenEvent added in v1.3.0

func (app *Application) ListenEvent(eventName string, objectMethod string, appointInfra ...interface{})

ListenMessage .

func (*Application) Logger added in v1.0.5

func (app *Application) Logger() *golog.Logger

Logger .

func (*Application) Run

func (app *Application) Run(serve iris.Runner, irisConf iris.Configuration)

Run .

type BeginRequest

type BeginRequest interface {
	BeginRequest(runtime Runtime)
}

BeginRequest .

type Bus

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

func GetBus

func GetBus(ctx iris.Context) *Bus

GetBus .

func (*Bus) Add

func (b *Bus) Add(key string, obj interface{})

Add .

func (*Bus) Get

func (b *Bus) Get(key string) (obj interface{}, ok bool)

Get .

func (*Bus) ToJson added in v1.2.1

func (b *Bus) ToJson() string

ToJson .

type DomainEventInfra added in v1.3.7

type DomainEventInfra interface {
	DomainEvent(producer, topic string, data []byte, runtime Runtime, header ...map[string]string)
}

type Entity added in v1.3.7

type Entity interface {
	DomainEvent(fun string, object interface{}, header ...map[string]string)
	Identity() string
	GetRuntime() Runtime
	SetProducer(string)
}

type EventBus added in v1.3.0

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

EventBus .

func (*EventBus) EventsPath added in v1.3.0

func (msgBus *EventBus) EventsPath(infra interface{}) (msgs map[string]string)

EventsPath .

type GORMRepository

type GORMRepository interface {
	DB() *gorm.DB
}

GORMRepository .

type Group added in v1.4.2

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

Group represents a class of work and forms a namespace in which units of work can be executed with duplicate suppression.

func (*Group) Do added in v1.4.2

func (g *Group) Do(key string, fn func() (interface{}, error)) (v interface{}, err error, shared bool)

Do executes and returns the results of the given function, making sure that only one execution is in-flight for a given key at a time. If a duplicate comes in, the duplicate caller waits for the original to complete and receives the same results. The return value shared indicates whether v was given to multiple callers.

func (*Group) DoChan added in v1.4.2

func (g *Group) DoChan(key string, fn func() (interface{}, error)) <-chan Result

DoChan is like Do but returns a channel that will receive the results when they are ready.

func (*Group) Forget added in v1.4.2

func (g *Group) Forget(key string)

Forget tells the singleflight to forget about a key. Future calls to Do for this key will call the function rather than waiting for an earlier call to complete.

type Infra added in v1.3.0

type Infra struct {
	Runtime Runtime `json:"-"`
}

Infra .

func (*Infra) BeginRequest added in v1.3.0

func (c *Infra) BeginRequest(rt Runtime)

BeginRequest .子实现多态

func (*Infra) DB added in v1.3.0

func (c *Infra) DB() (db *gorm.DB)

DB .

func (*Infra) NewFastRequest added in v1.3.0

func (c *Infra) NewFastRequest(url string) Request

NewFastRequest .

func (*Infra) NewH2CRequest added in v1.3.0

func (c *Infra) NewH2CRequest(url string) Request

NewH2CRequest .

func (*Infra) Redis added in v1.3.0

func (c *Infra) Redis() redis.Cmdable

Redis .

type InfraPool added in v1.3.0

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

InfraPool .

func (*InfraPool) Closeing added in v1.5.0

func (pool *InfraPool) Closeing(f func())

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{})
	GetService(ctx iris.Context, service interface{})
	AsyncCachePreheat(f func(repo *Repository))
	CachePreheat(f func(repo *Repository))
	//BindInfra 如果是单例 com是对象, 如果是多例,com是函数
	BindInfra(single bool, com interface{})
	GetInfra(ctx iris.Context, com interface{})
	//监听事件
	ListenEvent(eventName string, objectMethod string, appointInfra ...interface{})
}

Initiator .

type JMap

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

func NewJMap

func NewJMap(openLock ...bool) *JMap

func (*JMap) AllKey

func (jm *JMap) AllKey() []interface{}

func (*JMap) DelAll

func (jm *JMap) DelAll()

func (*JMap) Exist

func (jm *JMap) Exist(key interface{}) bool

func (*JMap) Get

func (jm *JMap) Get(key interface{}, value interface{}) error

func (*JMap) Interface

func (jm *JMap) Interface(key interface{}) interface{}

func (*JMap) Remove

func (jm *JMap) Remove(key interface{})

func (*JMap) Set

func (jm *JMap) Set(key interface{}, value interface{})

func (*JMap) SetOrStore

func (jm *JMap) SetOrStore(key interface{}, value interface{}) (v interface{}, set bool)

type Logger

type Logger interface {
	Print(v ...interface{})
	Printf(format string, args ...interface{})
	Println(v ...interface{})
	Log(level golog.Level, v ...interface{})
	Logf(level golog.Level, format string, args ...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 Pager added in v1.1.0

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

Pager 分页器

func (*Pager) Execute added in v1.1.0

func (p *Pager) Execute(db *gorm.DB, object interface{}) (e error)

Execute .

func (*Pager) Order added in v1.1.5

func (p *Pager) Order() interface{}

Order .

func (*Pager) TotalPage added in v1.1.0

func (p *Pager) TotalPage() int

TotalPage .

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.

type QueryBuilder

type QueryBuilder interface {
	Execute(db *gorm.DB, object interface{}) (e error)
	Order() interface{}
}

QueryBuilder .

type Reorder added in v1.1.0

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

Reorder .

func (*Reorder) NewPager added in v1.1.0

func (o *Reorder) NewPager(page, pageSize int) *Pager

NewPager .

func (*Reorder) Order added in v1.1.0

func (o *Reorder) Order() interface{}

Order .

type Repository

type Repository struct {
	Runtime Runtime
}

Repository .

func (*Repository) BeginRequest

func (repo *Repository) BeginRequest(rt Runtime)

BeginRequest .

func (*Repository) DB

func (repo *Repository) DB() (db *gorm.DB)

DB .

func (*Repository) MadeEntity added in v1.3.7

func (repo *Repository) MadeEntity(entity interface{})

MadeEntity .

func (*Repository) NewAscOrder

func (repo *Repository) NewAscOrder(field string, fields ...string) *Reorder

NewAscOrder .

func (*Repository) NewDescOrder

func (repo *Repository) NewDescOrder(field string, fields ...string) *Reorder

NewDescOrder .

func (*Repository) NewFastRequest

func (repo *Repository) NewFastRequest(url string) Request

NewFastRequest .

func (*Repository) NewH2CRequest

func (repo *Repository) NewH2CRequest(url string) Request

NewH2CRequest .

func (*Repository) Redis

func (repo *Repository) Redis() redis.Cmdable

Redis .

func (*Repository) SingleFlight added in v1.4.2

func (repo *Repository) SingleFlight(key string, value, takeObject interface{}, fn func() (interface{}, error)) error

SingleFlight .

type RepositoryPool

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

RepositoryPool .

type Request

type Request requests.Request

Request .

type Result added in v1.4.2

type Result struct {
	Val    interface{}
	Err    error
	Shared bool
}

Result holds the results of Do, so they can be passed on a channel.

type Runtime

type Runtime interface {
	Ctx() iris.Context
	Logger() Logger
	Store() *memstore.Store
	Prometheus() *Prometheus
}

Runtime .

type Scanner

type Scanner interface {
	Scan(src interface{}) error
}

type ServicePool

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

ServicePool .

type SingleBoot added in v1.1.9

type SingleBoot interface {
	Iris() *iris.Application
	EventsPath(infra interface{}) map[string]string
	Closeing(func())
}

SingleBoot .

type Store

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

func (*Store) Exist

func (s *Store) Exist(key interface{}) bool

Exist .

func (*Store) Get

func (s *Store) Get(key interface{}, value interface{}) error

Get .

func (*Store) Keys

func (s *Store) Keys() []interface{}

Keys .

func (*Store) Remove

func (s *Store) Remove(key interface{})

Remove .

func (*Store) RemoveAll

func (s *Store) RemoveAll()

RemoveAll .

func (*Store) Set

func (s *Store) Set(key interface{}, value interface{})

Set .

func (*Store) SetOrStore

func (s *Store) SetOrStore(key interface{}, value interface{}) (v interface{}, set bool)

SetOrStore .

func (*Store) ToInterface

func (s *Store) ToInterface(key interface{}) interface{}

Interface .

func (*Store) ToMap

func (s *Store) ToMap() map[interface{}]interface{}

ToMap .

func (*Store) Values

func (s *Store) Values() []interface{}

Values .

type UnitTest added in v1.4.0

type UnitTest interface {
	GetService(service interface{})
	GetRepository(repository interface{})
	InstallGorm(f func() (db *gorm.DB))
	InstallRedis(f func() (client redis.Cmdable))
	Run()
	SetRequest(request *http.Request)
	MadeEntity(entity interface{})
	InstallDomainEventInfra(eventInfra DomainEventInfra)
	NewDomainEventInfra(call ...func(producer, topic string, data []byte, header map[string]string)) DomainEventInfra
}

type UnitTestImpl added in v1.4.1

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

func (*UnitTestImpl) GetRepository added in v1.4.1

func (u *UnitTestImpl) GetRepository(repository interface{})

func (*UnitTestImpl) GetService added in v1.4.1

func (u *UnitTestImpl) GetService(service interface{})

func (*UnitTestImpl) InstallDomainEventInfra added in v1.4.1

func (u *UnitTestImpl) InstallDomainEventInfra(eventInfra DomainEventInfra)

func (*UnitTestImpl) InstallGorm added in v1.4.1

func (u *UnitTestImpl) InstallGorm(f func() (db *gorm.DB))

func (*UnitTestImpl) InstallRedis added in v1.4.1

func (u *UnitTestImpl) InstallRedis(f func() (client redis.Cmdable))

func (*UnitTestImpl) MadeEntity added in v1.4.1

func (u *UnitTestImpl) MadeEntity(entity interface{})

func (*UnitTestImpl) NewDomainEventInfra added in v1.4.1

func (u *UnitTestImpl) NewDomainEventInfra(call ...func(producer, topic string, data []byte, header map[string]string)) DomainEventInfra

func (*UnitTestImpl) Run added in v1.4.1

func (u *UnitTestImpl) Run()

func (*UnitTestImpl) SetRequest added in v1.4.1

func (u *UnitTestImpl) SetRequest(request *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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