pool

package
v0.4.16 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoPool

type GoPool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

GoPool golang资源池

func NewGoPool

func NewGoPool() *GoPool

NewGoPool 创建一个golang资源池

func (*GoPool) Acquire

func (gp *GoPool) Acquire() (interface{}, error)

Acquire 从资源池中获取一个资源

func (*GoPool) AcquireDecode

func (gp *GoPool) AcquireDecode(v interface{}) error

AcquireDecode 从资源池中获取一个资源, 并解析到v

func (*GoPool) AcquireString added in v0.2.4

func (gp *GoPool) AcquireString() (string, error)

AcquireString 从资源池中获取一个资源

func (*GoPool) Clear

func (gp *GoPool) Clear()

Clear 清空资源池

func (*GoPool) RefreshConfig added in v0.4.14

func (gp *GoPool) RefreshConfig(config.ServicePoolConfig) error

RefreshConfigs 刷新配置

func (*GoPool) Release

func (gp *GoPool) Release(v interface{}) error

Release 释放一个资源到资源池

func (*GoPool) ReleaseEncode

func (gp *GoPool) ReleaseEncode(v interface{}) error

ReleaseEncode 释放一个资源到资源池

func (*GoPool) ReleaseString added in v0.2.4

func (gp *GoPool) ReleaseString(v string) error

ReleaseString 释放一个资源到资源池

type Pool

type Pool interface {

	// AcquireDecode 从资源池中获取一个资源
	AcquireDecode(v interface{}) error
	// ReleaseEncode 释放一个资源到资源池
	ReleaseEncode(v interface{}) error
	// AcquireString 从资源池中获取一个资源
	AcquireString() (string, error)
	// ReleaseString 释放一个资源到资源池
	ReleaseString(string) error
	// Clear 清空资源池
	Clear()
	// RefreshConfigs 刷新配置
	RefreshConfig(config.ServicePoolConfig) error
}

Pool 资源池接口

type RedisPool

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

RedisPool 实现 Pool 接口

func NewRedisPool

func NewRedisPool(ctx context.Context, cli *redis.Client, rdsKey string, conf config.ServicePoolConfig) *RedisPool

NewRedisPool 创建一个新的 服务池 每次新建一个服务池时,会清空原有服务池

func (*RedisPool) Acquire

func (rp *RedisPool) Acquire() (interface{}, error)

Acquire 从资源池中获取一个资源, 返回值为redis.z 不需要key

func (*RedisPool) AcquireDecode

func (rp *RedisPool) AcquireDecode(v interface{}) error

AcquireDecode 从资源池中获取一个资源, 并json解析到v

func (*RedisPool) AcquireString added in v0.2.4

func (rp *RedisPool) AcquireString() (string, error)

AcquireString 从资源池中获取一个资源, 返回值为string

func (*RedisPool) Clear

func (rp *RedisPool) Clear()

Clear 清空资源池

func (*RedisPool) RefreshConfig added in v0.4.14

func (rp *RedisPool) RefreshConfig(newConf config.ServicePoolConfig) error

RefreshConfig 刷新配置

func (*RedisPool) Release

func (rp *RedisPool) Release(v interface{}) error

Release 释放一个资源到资源池, v为redis.z

func (*RedisPool) ReleaseEncode

func (rp *RedisPool) ReleaseEncode(v interface{}) error

ReleaseEncode 释放一个资源到资源池, 并json编码

func (*RedisPool) ReleaseString added in v0.2.4

func (rp *RedisPool) ReleaseString(v string) error

ReleaseString 释放一个资源到资源池, v为string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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