Documentation
¶
Overview ¶
travel 项目 第三发 插件包 插件包括 ffmpeg (用于音视频处理的工具) nats,pusher (简单站内消息通知工具,简单rpc服务) qrcode (二维码处理工具插件) qinniu (oss 七牛云服务)
Index ¶
- Constants
- func AppendCertificate(Url string, expire int64) string
- func GetConfigureCentreRepositoryMangerInstance() *configureCentreRepositoryMangerImpl
- func GetEtcdClient() (*clientv3.Client, error)
- func GetOssAccessUrl(key string, ossName string, bucket string) string
- func GetQinNiuProperties() map[string]string
- func GetQinNiuPropertiesKeys() []string
- func GetQinNiuProperty(key string, defaults ...string) string
- func NewErrorResponse() []byte
- func NewWatchHandler(handler EtcdWatcherHandler) func(watchChan clientv3.WatchChan)
- func ScreenShot(filename string, storage string, services ...FFmpegPluginInterface) bool
- type CContext
- type ConfigBootStrap
- type ConfigureCentreRepository
- type ContextLimit
- type EtcdConfigureCentreRepository
- type EtcdWatcherHandler
- type FFmpegPluginInterface
- type LimitResult
- type Limiter
- type MapperDecoder
- type MsgRpc
- type NatsConfig
- type NatsPlugin
- type Options
- type Oss
- type OssParams
- type OssPlugin
- func (this *OssPlugin) Auth() error
- func (this *OssPlugin) CreatePolicy(jsonData ...string) *OssPlugin
- func (this *OssPlugin) CreateUploader(params *OssParams, configures ...func(*storage.Config)) func(context.Context, ...func(*storage.PutExtra)) (interface{}, error)
- func (this *OssPlugin) GetAccessKey() string
- func (this *OssPlugin) GetBucket(typ string) string
- func (this *OssPlugin) GetPolicy() *storage.PutPolicy
- func (this *OssPlugin) GetSecretKey() string
- func (this *OssPlugin) Lock()
- func (this *OssPlugin) PluginName() string
- func (this *OssPlugin) Register()
- func (this *OssPlugin) UnLock()
- type PluginInterface
- type Pusher
- func (this *Pusher) Close()
- func (this *Pusher) GetChannel() string
- func (this *Pusher) GetTimeOut() time.Duration
- func (this *Pusher) Init()
- func (this *Pusher) Push(channel string, data interface{}) error
- func (this *Pusher) Queue(channel, queue string, cb interface{}) (*nats.Subscription, error)
- func (this *Pusher) QueueSubscribe(channel, queue string, cb interface{}) (*nats.Subscription, error)
- func (this *Pusher) RpcCall(method string, data interface{}, responsePtr interface{}, ...) error
- func (this *Pusher) RpcService(method string, handler func(string, []byte) (interface{}, error)) (*nats.Subscription, error)
- func (this *Pusher) Send(data []byte) error
- func (this *Pusher) SetChannel(channel string) PusherInterface
- func (this *Pusher) SetTimeOut(duration time.Duration) MsgRpc
- func (this *Pusher) Subscribe(channel string, handler interface{}) (*nats.Subscription, error)
- func (this *Pusher) Worker(handler interface{}) (*nats.Subscription, error)
- type PusherInterface
- type Qrcode
- func (this *Qrcode) Create(content string, options ...int) ([]byte, error)
- func (this *Qrcode) Decode(filename string) (*qrcode2.Matrix, error)
- func (this *Qrcode) GetLevels() []int
- func (this *Qrcode) GetSizes() []int
- func (this *Qrcode) PluginName() string
- func (this *Qrcode) Register()
- func (this *Qrcode) Save(content string, options *Options) error
- type TokenEntry
- type TokenLimiterProvider
- type WatchArgs
Constants ¶
View Source
const ( EtcdProvider = "etcd" EtcdEndpointsEnvKey = "ETCD_ENDPOINTS" )
View Source
const ( LimiterPlugin = "limiter" LimiterTokenPolicy = "token" PolicyKey = "policy" GlobalPolicyEnvKey = "LIMIT_POLICY" TokenCtxValueKey = "token" MacCtxValueKey = "mac" MinAccessTimeInterval = 100 * time.Microsecond // api 访问时间间隔 MaxAccessTimes = 10 // api 最大访问次数 )
View Source
const ( NatsUserKey = "NATS_USER" NatsName = "NATS_NAME" NatsPassword = "NATS_PASSWORD" NatsConnUrl = "NATS_CONN_URL" NatsNkey = "NATS_NKEY" NatsSeedKey = "NATS_SEED_KEY" NatsTokenKey = "NATS_TOKEN" )
View Source
const ( OssPluginName = "oss" QinNiuPrefixKey = "QINNIU_PREFIX" QinNiuAccessKey = "AK" QinNiuSecretKey = "SK" QinNiuBucketImg = "IMG" QinNiuBucketVideo = "VIDEO" QinNiuReturnBody = "RETURN_BODY" QinNiuCallbackUrl = "CALLBACK_URL" OssProviderQinNiu = "QinNiu" OssDefaultExpires = 1800 )
View Source
const (
QrcodePluginName = "qrcode"
)
Variables ¶
This section is empty.
Functions ¶
func AppendCertificate ¶
func GetConfigureCentreRepositoryMangerInstance ¶
func GetConfigureCentreRepositoryMangerInstance() *configureCentreRepositoryMangerImpl
func GetEtcdClient ¶
func GetQinNiuProperties ¶
func GetQinNiuPropertiesKeys ¶
func GetQinNiuPropertiesKeys() []string
func GetQinNiuProperty ¶
func NewErrorResponse ¶
func NewErrorResponse() []byte
func NewWatchHandler ¶
func NewWatchHandler(handler EtcdWatcherHandler) func(watchChan clientv3.WatchChan)
func ScreenShot ¶
func ScreenShot(filename string, storage string, services ...FFmpegPluginInterface) bool
截图
Types ¶
type CContext ¶
type CContext struct { TimeoutFn context.CancelFunc Cancel context.CancelFunc }
type ConfigBootStrap ¶
type ConfigBootStrap interface {
Boot()
}
type ConfigureCentreRepository ¶
type ConfigureCentreRepository interface { Del(keys []string, appId ...string) int Put(key string, value interface{}, appId ...string) error Get(key string, appId ...string) (map[string]string, error) Pull(appId string) (map[string]string, error) }
func EtcdConfigureCentreRepositoryOf ¶
func EtcdConfigureCentreRepositoryOf() ConfigureCentreRepository
type ContextLimit ¶
type ContextLimit interface { GetPolicy() string Ctx() context.Context SetPolicy(name string) ContextLimit SetValue(name string, value interface{}) ContextLimit }
func NewContextLimit ¶
func NewContextLimit() ContextLimit
type EtcdWatcherHandler ¶
type FFmpegPluginInterface ¶
type FFmpegPluginInterface interface { GetScreenShotAt() string SetScreenShotAt(at time.Duration) SetBinary(bin string) FFmpegPluginInterface SaveScreenShot(file string, storage ...string) string }
截图
func GetFfmpeg ¶
func GetFfmpeg() FFmpegPluginInterface
type LimitResult ¶
type Limiter ¶
type Limiter interface { Get(name string, ctx ContextLimit) func() *LimitResult New(ContextLimit) func(ctx ContextLimit) *LimitResult SetProvider(name string, provider func(ctx ContextLimit) *LimitResult) PluginInterface }
Limiter 限流器
func GetLimiter ¶
func GetLimiter() Limiter
type MsgRpc ¶
type MsgRpc interface { Close() GetTimeOut() time.Duration SetTimeOut(duration time.Duration) MsgRpc Worker(handler interface{}) (*nats.Subscription, error) RpcCall(method string, data interface{}, responsePtr interface{}, timeOut ...time.Duration) error RpcService(method string, handler func(string, []byte) (interface{}, error)) (*nats.Subscription, error) }
type NatsConfig ¶
type NatsConfig struct { Name string `json:"name"` ConnUrl string `json:"connUrl"` Nkey string `json:"nkey,omitempty"` User string `json:"user,omitempty"` NkeySeed string `json:"nkeySeed,omitempty"` Password string `json:"password,omitempty"` Token string `json:"token,omitempty"` }
配置
func NewNatsConfig ¶
func NewNatsConfig() *NatsConfig
func NewNatsConfigByFile ¶
func NewNatsConfigByFile(file string) *NatsConfig
type NatsPlugin ¶
type NatsPlugin struct { Name string `json:"name"` Config *NatsConfig `json:"config"` // contains filtered or unexported fields }
插件
func GetNatsPlugin ¶
func GetNatsPlugin() *NatsPlugin
func (*NatsPlugin) Init ¶
func (this *NatsPlugin) Init()
func (*NatsPlugin) PluginName ¶
func (this *NatsPlugin) PluginName() string
func (*NatsPlugin) Register ¶
func (this *NatsPlugin) Register()
type Options ¶
type Options struct { Size int `json:"size"` // 二维码 (宽 X 高) FileName string `json:"filename"` // 文件保存名路径 BackgroundColor color.Color `json:"backgroundColor"` // 背景色 ForegroundColor color.Color `json:"foregroundColor"` // 颜色 Level qrcode.RecoveryLevel `json:"level"` // 质量 Auto bool `json:"auto"` // 是否自动扩展 减少白边 }
func (*Options) GetLevel ¶
func (this *Options) GetLevel() qr.ErrorCorrectionLevel
func (*Options) GetStorage ¶
type OssParams ¶
type OssParams struct { Provider string `json:"provider"` // 服务提供 TypeName string `json:"type"` // 图片 | 视频类型 IMG , VIDEO 按类型自动获取 bucket Token string `json:"token,omitempty"` // 上传令牌 Bucket string `json:"bucket,omitempty"` // 存储桶 ,有对应类型时可选 Storage storage.Config `json:"storage"` // 存储配置 [ 区域,https, cdn加速域名] Result interface{} `json:"result"` // 上传结果对象 Reader io.Reader `json:",omitempty"` // 上传io流 Size int64 `json:"size,omitempty"` // 流大小 File string `json:"file,omitempty"` // 上传本地文件地址 Key string `json:"key"` // 上传文件保存名字 Expires uint64 `json:"expires,omitempty"` // token 有效时间 Extras *storage.PutExtra `json:"extras"` // 上传扩展信息 PutPolicy *storage.PutPolicy `json:"put_policy"` // 上传策略 }
type OssPlugin ¶
func (*OssPlugin) CreatePolicy ¶
func (*OssPlugin) CreateUploader ¶
func (this *OssPlugin) CreateUploader(params *OssParams, configures ...func(*storage.Config)) func( context.Context, ...func(*storage.PutExtra)) (interface{}, error)
CreateUploader 构建上传函数
func (*OssPlugin) GetAccessKey ¶
func (*OssPlugin) GetSecretKey ¶
func (*OssPlugin) PluginName ¶
type PluginInterface ¶
type PluginInterface interface { Register() PluginName() string }
type Pusher ¶
type Pusher struct { Client *NatsPlugin Timeout time.Duration // contains filtered or unexported fields }
func (*Pusher) GetChannel ¶
func (*Pusher) GetTimeOut ¶
func (*Pusher) QueueSubscribe ¶
func (this *Pusher) QueueSubscribe(channel, queue string, cb interface{}) (*nats.Subscription, error)
队列订阅
func (*Pusher) RpcCall ¶
func (this *Pusher) RpcCall(method string, data interface{}, responsePtr interface{}, timeOut ...time.Duration) error
远程调用
func (*Pusher) RpcService ¶
func (this *Pusher) RpcService(method string, handler func(string, []byte) (interface{}, error)) (*nats.Subscription, error)
调用远程服务
func (*Pusher) SetChannel ¶
func (this *Pusher) SetChannel(channel string) PusherInterface
type PusherInterface ¶
type PusherInterface interface { GetChannel() string Push(string, interface{}) error SetChannel(string) PusherInterface Subscribe(string, interface{}) (*nats.Subscription, error) Close() }
func GetPusher ¶
func GetPusher() PusherInterface
type Qrcode ¶
func (*Qrcode) PluginName ¶
type TokenEntry ¶
type TokenLimiterProvider ¶
type TokenLimiterProvider interface {
Handler(ctx ContextLimit) *LimitResult
}
func NewTokenLimiterProvider ¶
Click to show internal directories.
Click to hide internal directories.