internal

package
v1.7.10 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WorkerKey = "freedom-worker-ctx"
)

Variables

This section is empty.

Functions

func ConvertAssign

func ConvertAssign(dest, src interface{}) error

func HandleBusMiddleware

func HandleBusMiddleware(worker Worker)

func InSlice

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

InSlice 是否在数组内

func NewMap

func NewMap(dst interface{}) error

NewMap

func NewSlice

func NewSlice(dsc interface{}, len int) error

NewSlice 创建数组

func Prepare

func Prepare(f func(Initiator))

Prepare app.BindController or app.BindControllerByParty.

func SliceDelete

func SliceDelete(arr interface{}, indexArr ...int) error

SliceDelete 删除数组指定下标元素

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

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

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

Register .

func (*Application) CreateH2CRunner

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

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

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 .

func (*Application) GetSingleInfra

func (app *Application) GetSingleInfra(com interface{})

GetSingleInfra .

func (*Application) InjectController

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

InjectController .

func (*Application) InstallBusMiddleware

func (app *Application) InstallBusMiddleware(handle ...BusHandler)

InstallBusMiddleware .

func (*Application) InstallDomainEventInfra

func (app *Application) InstallDomainEventInfra(eventInfra DomainEventInfra)

InstallDomainEventInfra .

func (*Application) InstallGorm

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

InstallGorm .

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 .

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) Iris

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

Iris .

func (*Application) ListenEvent

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

ListenMessage .

func (*Application) Logger

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

Logger .

func (*Application) Run

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

Run .

func (*Application) Start

func (app *Application) Start(f func(starter Starter))

Start .

type BeginRequest

type BeginRequest interface {
	BeginRequest(Worker Worker)
}

BeginRequest .

type Builder

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

Builder

func (*Builder) Execute

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

Execute .

func (*Builder) Order

func (b *Builder) Order() interface{}

func (*Builder) SelectColumn

func (b *Builder) SelectColumn(column ...string) *Builder

SelectColumn .

func (*Builder) SelectPrimary

func (b *Builder) SelectPrimary() *Builder

SelectPrimary .

func (*Builder) SetPage

func (b *Builder) SetPage(page, pageSize int) *Builder

SetPage .

func (*Builder) TotalPage

func (p *Builder) TotalPage() int

TotalPage .

type Bus

type Bus struct {
	http.Header
}

func (*Bus) Add

func (b *Bus) Add(key, obj string)

Add .

func (*Bus) Del

func (b *Bus) Del(key string)

Set .

func (*Bus) Get

func (b *Bus) Get(key string) string

Get .

func (*Bus) Set

func (b *Bus) Set(key, obj string)

Set .

type BusHandler

type BusHandler func(Worker)

type DomainEventInfra

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

type Entity

type Entity interface {
	DomainEvent(eventName string, object interface{}, header ...map[string]string)
	Identity() string
	GetWorker() Worker
	SetProducer(string)
	Marshal() []byte
}

type EventBus

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

EventBus .

func (*EventBus) EventsPath

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

EventsPath .

type GORMRepository

type GORMRepository interface {
	DB() *gorm.DB
	InjectBaseEntity(entity Entity)
	InjectBaseEntitys(entitys interface{})
	GetWorker() Worker
}

GORMRepository .

type Infra

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

Infra .

func (*Infra) BeginRequest

func (c *Infra) BeginRequest(rt Worker)

BeginRequest .子实现多态

func (*Infra) DB

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

DB .

func (*Infra) GetWorker added in v1.7.5

func (infra *Infra) GetWorker() Worker

GetWorker .

func (*Infra) InjectBaseEntity added in v1.7.5

func (infra *Infra) InjectBaseEntity(entity Entity)

InjectBaseEntity .

func (*Infra) InjectBaseEntitys added in v1.7.5

func (infra *Infra) InjectBaseEntitys(entitys interface{})

InjectBaseEntity .

func (*Infra) NewH2CRequest

func (infra *Infra) 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 (*Infra) NewHttpRequest

func (infra *Infra) NewHttpRequest(url string, transferBus ...bool) requests.Request

NewHttpRequest, transferBus : Whether to pass the context, turned on by default. Typically used for tracking internal services.

func (*Infra) Other added in v1.7.5

func (infra *Infra) Other(obj interface{})

GetOther .

func (*Infra) Redis

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

Redis .

type InfraPool

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

InfraPool .

func (*InfraPool) Closeing

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

func (*InfraPool) GetSingleInfra

func (pool *InfraPool) GetSingleInfra(ptr reflect.Value) bool

GetSingleInfra .

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{})
	//BindInfra 如果是单例 com是对象, 如果是多例,com是函数
	BindInfra(single bool, com interface{})
	GetInfra(ctx iris.Context, com interface{})
	//监听事件
	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
}

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 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) KafkaProducerWithLabelValues

func (p *Prometheus) KafkaProducerWithLabelValues(topic string, e error, starTime time.Time)

func (*Prometheus) OrmWithLabelValues

func (p *Prometheus) OrmWithLabelValues(model, method string, e error, starTime time.Time)

func (*Prometheus) RegisterCounter

func (p *Prometheus) RegisterCounter(conter *prometheus.CounterVec)

func (*Prometheus) RegisterHistogram

func (p *Prometheus) RegisterHistogram(histogram *prometheus.HistogramVec)

type QueryBuilder

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

QueryBuilder .

type Reorder

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

Reorder .

func (*Reorder) NewBuilder

func (o *Reorder) NewBuilder() *Builder

NewBuilder .

func (*Reorder) NewPageBuilder

func (o *Reorder) NewPageBuilder(page, pageSize int) *Builder

NewPageBuilder .

func (*Reorder) Order

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

Order .

type Repository

type Repository struct {
	Worker Worker
}

Repository .

func (*Repository) BeginRequest

func (repo *Repository) BeginRequest(rt Worker)

BeginRequest .

func (*Repository) DB

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

DB .

func (*Repository) GetWorker

func (repo *Repository) GetWorker() Worker

GetWorker .

func (*Repository) InjectBaseEntity

func (repo *Repository) InjectBaseEntity(entity Entity)

InjectBaseEntity .

func (*Repository) InjectBaseEntitys

func (repo *Repository) InjectBaseEntitys(entitys interface{})

InjectBaseEntity .

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

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.

func (*Repository) NewORMAscBuilder

func (repo *Repository) NewORMAscBuilder(column string, columns ...string) *Reorder

NewORMAscBuilder .

func (*Repository) NewORMBuilder

func (repo *Repository) NewORMBuilder() *Builder

NewORMBuilder .

func (*Repository) NewORMDescBuilder

func (repo *Repository) NewORMDescBuilder(column string, columns ...string) *Reorder

NewORMDescBuilder .

func (*Repository) Other

func (repo *Repository) Other(obj interface{})

Other .

func (*Repository) Redis

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

Redis .

func (*Repository) SourceDB

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

SourceDB .

type RepositoryPool

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

RepositoryPool .

type Scanner

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

type ServicePool

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

ServicePool .

type SingleBoot

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

SingleBoot .

type Starter

type Starter interface {
	Iris() *iris.Application
	//异步缓存预热
	AsyncCachePreheat(f func(repo *Repository))
	//同步缓存预热
	CachePreheat(f func(repo *Repository))
	GetSingleInfra(com interface{})
}

Starter .

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

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)
	InjectBaseEntity(entity interface{})
	InstallDomainEventInfra(eventInfra DomainEventInfra)
	NewDomainEventInfra(call ...func(producer, topic string, data []byte, header map[string]string)) DomainEventInfra
}

type UnitTestImpl

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

func (*UnitTestImpl) GetRepository

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

func (*UnitTestImpl) GetService

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

func (*UnitTestImpl) InjectBaseEntity

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

func (*UnitTestImpl) InstallDomainEventInfra

func (u *UnitTestImpl) InstallDomainEventInfra(eventInfra DomainEventInfra)

func (*UnitTestImpl) InstallGorm

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

func (*UnitTestImpl) InstallRedis

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

func (*UnitTestImpl) NewDomainEventInfra

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

func (*UnitTestImpl) Run

func (u *UnitTestImpl) Run()

func (*UnitTestImpl) SetRequest

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

type Worker

type Worker interface {
	IrisContext() iris.Context
	Logger() Logger
	Store() *memstore.Store
	Bus() *Bus
	Context() stdContext.Context
	WithContext(stdContext.Context)
	StartTime() time.Time
	DeferRecycle()
	IsDeferRecycle() bool
	Rand() *rand.Rand
}

Worker .

Jump to

Keyboard shortcuts

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