runtime

package
v1.7.11 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCache

func NewCache(prefix string, store storage.AdapterCache) storage.AdapterCache

NewCache 创建对应上下文缓存

func NewLocker

func NewLocker(prefix string, locker storage.AdapterLocker) storage.AdapterLocker

NewLocker 创建对应上下文分布式锁

func NewModeration added in v1.4.13

func NewModeration(prefix string, moderation moderation.AdapterModeration) moderation.AdapterModeration

NewModeration 创建对应上下文缓存

func NewQueue

func NewQueue(prefix string, queue storage.AdapterQueue) storage.AdapterQueue

NewQueue 创建对应上下文队列

Types

type Amqp

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

func (*Amqp) PublishOnQueue

func (e *Amqp) PublishOnQueue(exchangeName, exchangeType, queueName, key, tag string, durableQueue bool, body interface{}) error

PublishOnQueue 发送消息

func (*Amqp) String

func (e *Amqp) String() string

String string输出

func (*Amqp) SubscribeToQueue

func (e *Amqp) SubscribeToQueue(exchangeName, exchangeType, queueName, key, tag string, durableQueue bool, consumerExclusive bool, f message.AmqpConsumerFunc) error

SubscribeToQueue 消费消息

type Application

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

func NewConfig

func NewConfig() *Application

NewConfig 默认值

func (*Application) GetAmqpAdapter

func (e *Application) GetAmqpAdapter() message.AdapterAmqp

GetAmqpAdapter 获取缓存

func (*Application) GetAmqpAdapters

func (e *Application) GetAmqpAdapters() map[string]message.AdapterAmqp

GetAmqpAdapters 获取缓存

func (*Application) GetAmqpKey

func (e *Application) GetAmqpKey(key string) message.AdapterAmqp

GetAmqpKey 获取带租户标记的amqp

func (*Application) GetAppRouters added in v1.3.25

func (e *Application) GetAppRouters() []func()

GetAppRouters 获取app的路由

func (*Application) GetCacheAdapter

func (e *Application) GetCacheAdapter() storage.AdapterCache

GetCacheAdapter 获取缓存

func (*Application) GetCachePrefix

func (e *Application) GetCachePrefix(key string) storage.AdapterCache

GetCachePrefix 获取带租户标记的cache

func (*Application) GetCasbin

func (e *Application) GetCasbin() map[string]*casbin.SyncedEnforcer

func (*Application) GetCasbinKey

func (e *Application) GetCasbinKey(key string) *casbin.SyncedEnforcer

GetCasbinKey 根据key获取casbin

func (*Application) GetConfig added in v1.3.25

func (e *Application) GetConfig(key string) interface{}

GetConfig 获取对应key的config

func (*Application) GetCrontab

func (e *Application) GetCrontab() map[string]*cron.Cron

GetCrontab 获取所有map里的crontab数据

func (*Application) GetCrontabKey

func (e *Application) GetCrontabKey(key string) *cron.Cron

GetCrontabKey 根据key获取crontab

func (*Application) GetDb

func (e *Application) GetDb() map[string]*gorm.DB

GetDb 获取所有map里的db数据

func (*Application) GetDbByKey

func (e *Application) GetDbByKey(key string) *gorm.DB

GetDbByKey 根据key获取db

func (*Application) GetEngine

func (e *Application) GetEngine() http.Handler

GetEngine 获取路由引擎

func (*Application) GetFileStoreAdapter

func (e *Application) GetFileStoreAdapter() storage.AdapterFileStore

GetFileStoreAdapter 获取缓存

func (*Application) GetFileStoreAdapters

func (e *Application) GetFileStoreAdapters() map[string]storage.AdapterFileStore

GetFileStoreAdapters 获取缓存

func (*Application) GetFileStoreKey

func (e *Application) GetFileStoreKey(key string) storage.AdapterFileStore

GetFileStoreKey 获取带租户标记的cos

func (*Application) GetHandler

func (e *Application) GetHandler() map[string][]func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)

func (*Application) GetHandlerPrefix

func (e *Application) GetHandlerPrefix(key string) []func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)

func (*Application) GetLocationBasedServiceAdapter added in v1.3.28

func (e *Application) GetLocationBasedServiceAdapter() lbs.AdapterLocationBasedService

GetLocationBasedServiceAdapter 获取LBS

func (*Application) GetLocationBasedServiceAdapters added in v1.3.28

func (e *Application) GetLocationBasedServiceAdapters() map[string]lbs.AdapterLocationBasedService

GetLocationBasedServiceAdapters 获取LBS

func (*Application) GetLocationBasedServiceKey added in v1.3.28

func (e *Application) GetLocationBasedServiceKey(key string) lbs.AdapterLocationBasedService

GetLocationBasedServiceKey 获取LBS

func (*Application) GetLockerAdapter

func (e *Application) GetLockerAdapter() storage.AdapterLocker

GetLockerAdapter 获取分布式锁

func (*Application) GetLockerPrefix

func (e *Application) GetLockerPrefix(key string) storage.AdapterLocker

func (*Application) GetLogger

func (e *Application) GetLogger() logger.Logger

GetLogger 获取日志组件

func (*Application) GetMailAdapter added in v1.3.13

func (e *Application) GetMailAdapter() message.AdapterMail

GetMailAdapter 获取缓存

func (*Application) GetMailAdapters added in v1.3.13

func (e *Application) GetMailAdapters() map[string]message.AdapterMail

GetMailAdapters 获取缓存

func (*Application) GetMailKey added in v1.3.13

func (e *Application) GetMailKey(key string) message.AdapterMail

GetMailKey 获取带租户标记的mail

func (*Application) GetMemoryQueue

func (e *Application) GetMemoryQueue(prefix string) storage.AdapterQueue

func (*Application) GetMiddleware

func (e *Application) GetMiddleware() map[string]interface{}

GetMiddleware 获取所有中间件

func (*Application) GetMiddlewareKey

func (e *Application) GetMiddlewareKey(key string) interface{}

GetMiddlewareKey 获取对应key的中间件

func (*Application) GetModerationAdapter added in v1.4.11

func (e *Application) GetModerationAdapter() moderation.AdapterModeration

GetModerationAdapter 获取缓存

func (*Application) GetModerationAdapters added in v1.4.11

func (e *Application) GetModerationAdapters() map[string]moderation.AdapterModeration

GetModerationAdapters 获取缓存

func (*Application) GetModerationKey added in v1.4.11

func (e *Application) GetModerationKey(key string) moderation.AdapterModeration

GetModerationKey 获取带租户标记的cos

func (*Application) GetPaymentServiceAdapter added in v1.4.10

func (e *Application) GetPaymentServiceAdapter() payment.AdapterPaymentService

GetPaymentServiceAdapter 获取支付

func (*Application) GetPaymentServiceAdapters added in v1.4.10

func (e *Application) GetPaymentServiceAdapters() map[string]payment.AdapterPaymentService

GetPaymentServiceAdapters 获取支付

func (*Application) GetPaymentServiceKey added in v1.4.10

func (e *Application) GetPaymentServiceKey(key string) payment.AdapterPaymentService

GetPaymentServiceKey 获取支付

func (*Application) GetQueueAdapter

func (e *Application) GetQueueAdapter() storage.AdapterQueue

GetQueueAdapter 获取队列适配器

func (*Application) GetQueueKey added in v1.5.6

func (e *Application) GetQueueKey(key string) storage.AdapterQueue

func (*Application) GetQueuePrefix

func (e *Application) GetQueuePrefix(key string, prefix string) storage.AdapterQueue

GetQueuePrefix 获取带租户标记的queue

func (*Application) GetRouter

func (e *Application) GetRouter() []Router

GetRouter 获取路由表

func (*Application) GetSmsAdapter added in v1.3.13

func (e *Application) GetSmsAdapter() message.AdapterSms

GetSmsAdapter 获取缓存

func (*Application) GetSmsAdapters added in v1.3.13

func (e *Application) GetSmsAdapters() map[string]message.AdapterSms

GetSmsAdapters 获取缓存

func (*Application) GetSmsKey added in v1.3.13

func (e *Application) GetSmsKey(key string) message.AdapterSms

GetSmsKey 获取带租户标记的sms

func (*Application) GetStreamMessage

func (e *Application) GetStreamMessage(id, stream string, value map[string]interface{}) (storage.Messager, error)

GetStreamMessage 获取队列需要用的message

func (*Application) GetThirdPartyAdapter added in v1.3.16

func (e *Application) GetThirdPartyAdapter() third_party.AdapterThirdParty

GetThirdPartyAdapter 获取缓存

func (*Application) GetThirdPartyAdapters added in v1.3.16

func (e *Application) GetThirdPartyAdapters() map[string]third_party.AdapterThirdParty

GetThirdPartyAdapters 获取缓存

func (*Application) GetThirdPartyKey added in v1.3.16

func (e *Application) GetThirdPartyKey(key string) third_party.AdapterThirdParty

GetThirdPartyKey 获取带租户标记的amqp

func (*Application) SetAmqpAdapter

func (e *Application) SetAmqpAdapter(key string, c message.AdapterAmqp)

SetAmqpAdapter 设置缓存

func (*Application) SetAppRouters added in v1.3.25

func (e *Application) SetAppRouters(appRouters func())

SetAppRouters 设置app的路由

func (*Application) SetCacheAdapter

func (e *Application) SetCacheAdapter(c storage.AdapterCache)

SetCacheAdapter 设置缓存

func (*Application) SetCasbin

func (e *Application) SetCasbin(key string, enforcer *casbin.SyncedEnforcer)

func (*Application) SetConfig added in v1.3.25

func (e *Application) SetConfig(key string, value interface{})

SetConfig 设置对应key的config

func (*Application) SetCrontab

func (e *Application) SetCrontab(key string, crontab *cron.Cron)

SetCrontab 设置对应key的crontab

func (*Application) SetDb

func (e *Application) SetDb(key string, db *gorm.DB)

SetDb 设置对应key的db

func (*Application) SetEngine

func (e *Application) SetEngine(engine http.Handler)

SetEngine 设置路由引擎

func (*Application) SetFileStoreAdapter

func (e *Application) SetFileStoreAdapter(key string, c storage.AdapterFileStore)

SetFileStoreAdapter 设置缓存

func (*Application) SetHandler

func (e *Application) SetHandler(key string, routerGroup func(r *gin.RouterGroup, hand ...*gin.HandlerFunc))

func (*Application) SetLocationBasedServiceAdapter added in v1.3.28

func (e *Application) SetLocationBasedServiceAdapter(key string, c lbs.AdapterLocationBasedService)

SetLocationBasedServiceAdapter 设置LBS

func (*Application) SetLockerAdapter

func (e *Application) SetLockerAdapter(c storage.AdapterLocker)

SetLockerAdapter 设置分布式锁

func (*Application) SetLogger

func (e *Application) SetLogger(l logger.Logger)

SetLogger 设置日志组件

func (*Application) SetMailAdapter added in v1.3.13

func (e *Application) SetMailAdapter(key string, c message.AdapterMail)

SetMailAdapter 设置缓存

func (*Application) SetMiddleware

func (e *Application) SetMiddleware(key string, middleware interface{})

SetMiddleware 设置中间件

func (*Application) SetModerationAdapter added in v1.4.11

func (e *Application) SetModerationAdapter(key string, c moderation.AdapterModeration)

SetModerationAdapter 设置缓存

func (*Application) SetPaymentServiceAdapter added in v1.4.10

func (e *Application) SetPaymentServiceAdapter(key string, c payment.AdapterPaymentService)

SetPaymentServiceAdapter 设置支付

func (*Application) SetQueueAdapter

func (e *Application) SetQueueAdapter(key string, c storage.AdapterQueue)

SetQueueAdapter 设置队列适配器

func (*Application) SetSmsAdapter added in v1.3.13

func (e *Application) SetSmsAdapter(key string, c message.AdapterSms)

SetSmsAdapter 设置缓存

func (*Application) SetThirdPartyAdapter added in v1.3.16

func (e *Application) SetThirdPartyAdapter(key string, c third_party.AdapterThirdParty)

SetThirdPartyAdapter 设置缓存

type Cache

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

func (Cache) Connect

func (e Cache) Connect() error

Connect 初始化

func (Cache) Decrease

func (e Cache) Decrease(key string) error

func (Cache) Del

func (e Cache) Del(key ...string) error

Del delete key in cache

func (Cache) DelPattern added in v1.3.30

func (e Cache) DelPattern(pattern string) error

DelPattern delete key in cache

func (Cache) Expire

func (e Cache) Expire(key string, dur time.Duration) error

func (Cache) Get

func (e Cache) Get(key string) (string, error)

Get val in cache

func (Cache) GetClient added in v1.3.30

func (e Cache) GetClient() interface{}

func (Cache) HashDel

func (e Cache) HashDel(hk string, key ...string) error

HashDel delete one key:value pair in hashtable cache

func (Cache) HashDelPattern added in v1.3.30

func (e Cache) HashDelPattern(hk, pattern string) error

HashDelPattern delete one key:value pair in hashtable cache

func (Cache) HashGet

func (e Cache) HashGet(hk, key string) (string, error)

HashGet get val in hashtable cache

func (Cache) HashKeys

func (e Cache) HashKeys(hk string) ([]string, error)

HashKeys get val in hashtable cache

func (Cache) HashSet

func (e Cache) HashSet(hk, key string, val interface{}, expire int) error

HashSet set val in hashtable cache

func (Cache) Increase

func (e Cache) Increase(key string) error

Increase value

func (Cache) Set

func (e Cache) Set(key string, val interface{}, expire int) error

Set val in cache

func (*Cache) SetPrefix

func (e *Cache) SetPrefix(prefix string)

SetPrefix 设置前缀

func (*Cache) String

func (e *Cache) String() string

String string输出

type FileStore

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

func (*FileStore) GetClient added in v1.3.14

func (e *FileStore) GetClient() interface{}

GetClient Put file to fileStores

func (*FileStore) String

func (e *FileStore) String() string

String string输出

func (*FileStore) Upload

func (e *FileStore) Upload(ctx context.Context, name, location string) (string, error)

Upload Put file to fileStores

type Locker

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

func (*Locker) Lock

func (e *Locker) Lock(key string, ttl int64, options *redislock.Options) (*redislock.Lock, error)

Lock 返回分布式锁对象

func (*Locker) String

func (e *Locker) String() string

type Mail added in v1.3.13

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

func (*Mail) Send added in v1.3.13

func (e *Mail) Send(address []string, body []byte) error

Send val by announces

func (*Mail) String added in v1.3.13

func (e *Mail) String() string

String string输出

type Moderation added in v1.4.11

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

func (*Moderation) AuditImage added in v1.4.11

func (e *Moderation) AuditImage(url string, fileSize int, result *int, label *string, score *int, detail *string, jobId *string) error

AuditImage 图片审核

func (*Moderation) AuditResult added in v1.4.13

func (e *Moderation) AuditResult(body *[]byte, result *int, label *string, score *int, detail *string, jobId *string) error

AuditResult 审核结果

func (*Moderation) AuditText added in v1.4.11

func (e *Moderation) AuditText(content string, result *int, label *string, score *int, detail *string, jobId *string) error

AuditText 文本审核

func (*Moderation) AuditVideo added in v1.4.11

func (e *Moderation) AuditVideo(url string, frame int32, jobId *string) error

AuditVideo 视频审核

func (*Moderation) GetClient added in v1.4.11

func (e *Moderation) GetClient() interface{}

func (*Moderation) String added in v1.4.11

func (e *Moderation) String() string

String string输出

type Queue

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

func (*Queue) Append

func (e *Queue) Append(message storage.Messager) error

Append 增加数据到生产者

func (*Queue) Register

func (e *Queue) Register(name string, f storage.ConsumerFunc)

Register 注册消费者

func (*Queue) Run

func (e *Queue) Run()

Run 运行

func (*Queue) Shutdown

func (e *Queue) Shutdown()

Shutdown 停止

func (*Queue) String

func (e *Queue) String() string

type Router

type Router struct {
	HttpMethod, RelativePath, Handler string
}

type Routers

type Routers struct {
	List []Router
}

type Runtime

type Runtime interface {
	// SetDb 多db设置,⚠️SetDbs不允许并发,可以根据自己的业务,例如app分库、host分库
	SetDb(key string, db *gorm.DB)
	GetDb() map[string]*gorm.DB
	GetDbByKey(key string) *gorm.DB

	SetCasbin(key string, enforcer *casbin.SyncedEnforcer)
	GetCasbin() map[string]*casbin.SyncedEnforcer
	GetCasbinKey(key string) *casbin.SyncedEnforcer

	// SetEngine 使用的路由
	SetEngine(engine http.Handler)
	GetEngine() http.Handler

	GetRouter() []Router

	// SetLogger 使用go-admin定义的logger,参考来源go-micro
	SetLogger(logger logger.Logger)
	GetLogger() logger.Logger

	// SetCrontab crontab
	SetCrontab(key string, crontab *cron.Cron)
	GetCrontab() map[string]*cron.Cron
	GetCrontabKey(key string) *cron.Cron

	// SetMiddleware middleware
	SetMiddleware(string, interface{})
	GetMiddleware() map[string]interface{}
	GetMiddlewareKey(key string) interface{}

	// SetCacheAdapter cache
	SetCacheAdapter(storage.AdapterCache)
	GetCacheAdapter() storage.AdapterCache
	GetCachePrefix(string) storage.AdapterCache

	GetMemoryQueue(string) storage.AdapterQueue
	SetQueueAdapter(string, storage.AdapterQueue)
	GetQueueAdapter() storage.AdapterQueue
	GetQueueKey(string) storage.AdapterQueue
	GetQueuePrefix(string, string) storage.AdapterQueue

	SetLockerAdapter(storage.AdapterLocker)
	GetLockerAdapter() storage.AdapterLocker
	GetLockerPrefix(string) storage.AdapterLocker

	SetSmsAdapter(string, message.AdapterSms)
	GetSmsAdapter() message.AdapterSms
	GetSmsAdapters() map[string]message.AdapterSms
	GetSmsKey(key string) message.AdapterSms

	SetMailAdapter(string, message.AdapterMail)
	GetMailAdapter() message.AdapterMail
	GetMailAdapters() map[string]message.AdapterMail
	GetMailKey(key string) message.AdapterMail

	SetFileStoreAdapter(string, storage.AdapterFileStore)
	GetFileStoreAdapter() storage.AdapterFileStore
	GetFileStoreAdapters() map[string]storage.AdapterFileStore
	GetFileStoreKey(string) storage.AdapterFileStore

	SetModerationAdapter(string, moderation.AdapterModeration)
	GetModerationAdapter() moderation.AdapterModeration
	GetModerationAdapters() map[string]moderation.AdapterModeration
	GetModerationKey(string) moderation.AdapterModeration

	SetAmqpAdapter(string, message.AdapterAmqp)
	GetAmqpAdapter() message.AdapterAmqp
	GetAmqpAdapters() map[string]message.AdapterAmqp
	GetAmqpKey(key string) message.AdapterAmqp

	SetThirdPartyAdapter(string, third_party.AdapterThirdParty)
	GetThirdPartyAdapter() third_party.AdapterThirdParty
	GetThirdPartyAdapters() map[string]third_party.AdapterThirdParty
	GetThirdPartyKey(key string) third_party.AdapterThirdParty

	SetLocationBasedServiceAdapter(string, lbs.AdapterLocationBasedService)
	GetLocationBasedServiceAdapter() lbs.AdapterLocationBasedService
	GetLocationBasedServiceAdapters() map[string]lbs.AdapterLocationBasedService
	GetLocationBasedServiceKey(string) lbs.AdapterLocationBasedService

	SetPaymentServiceAdapter(string, payment.AdapterPaymentService)
	GetPaymentServiceAdapter() payment.AdapterPaymentService
	GetPaymentServiceAdapters() map[string]payment.AdapterPaymentService
	GetPaymentServiceKey(string) payment.AdapterPaymentService

	SetHandler(key string, routerGroup func(r *gin.RouterGroup, hand ...*gin.HandlerFunc))
	GetHandler() map[string][]func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)
	GetHandlerPrefix(key string) []func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)

	GetStreamMessage(id, stream string, value map[string]interface{}) (storage.Messager, error)

	GetConfig(key string) interface{}
	SetConfig(key string, value interface{})

	// SetAppRouters set AppRouter
	SetAppRouters(appRouters func())
	GetAppRouters() []func()
}

type Sms added in v1.3.13

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

func (*Sms) GetClient added in v1.4.11

func (e *Sms) GetClient() interface{}

func (*Sms) Send added in v1.3.13

func (e *Sms) Send(addresses []string, template string, params map[string]string) error

Send val by announces

func (*Sms) String added in v1.3.13

func (e *Sms) String() string

String string输出

type ThirdParty added in v1.3.16

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

func NewThirdParty added in v1.4.13

func NewThirdParty(prefix string, thirdParty third_party.AdapterThirdParty) *ThirdParty

NewThirdParty 创建对应上下文缓存

func (*ThirdParty) GetAccessToken added in v1.3.16

func (e *ThirdParty) GetAccessToken(cache storage.AdapterCache) (string, error)

func (*ThirdParty) GetConnectUrl added in v1.3.16

func (e *ThirdParty) GetConnectUrl(state, scope string, popUp bool, redirectPath string) (string, error)

func (*ThirdParty) GetJSApiTicket added in v1.3.30

func (e *ThirdParty) GetJSApiTicket(cache storage.AdapterCache) (string, error)

func (*ThirdParty) GetUserAccessToken added in v1.3.16

func (e *ThirdParty) GetUserAccessToken(code string) (string, error)

func (*ThirdParty) GetUserInfo added in v1.3.16

func (e *ThirdParty) GetUserInfo(userAccessToken, openId string) (string, error)

func (*ThirdParty) RefreshUserToken added in v1.3.30

func (e *ThirdParty) RefreshUserToken(refreshToken string, appId string) (string, error)

func (*ThirdParty) SendTemplateMessage added in v1.3.16

func (e *ThirdParty) SendTemplateMessage(cache storage.AdapterCache, openId, templateId, url string, data []byte, rootData []byte) (string, error)

SendTemplateMessage 发送模板消息

func (*ThirdParty) String added in v1.3.16

func (e *ThirdParty) String() string

String string输出

Jump to

Keyboard shortcuts

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