Documentation ¶
Index ¶
- Constants
- Variables
- type Chain
- type Local
- type LocalConfiguration
- type LocalOption
- type PgxPool
- func (chain *PgxPool) Close() error
- func (chain *PgxPool) CreateTable(ctx context.Context) error
- func (chain *PgxPool) Forward(ctx context.Context, key string, target int64) (int64, error)
- func (chain *PgxPool) Last(ctx context.Context, key string) (int64, error)
- func (chain *PgxPool) Next(ctx context.Context, key string) (int64, error)
- func (chain *PgxPool) NextN(ctx context.Context, key string, count int64) (int64, error)
- type PgxPoolConfiguration
- type PgxPoolOption
- type PostgreSQL
Constants ¶
const Table = "serialkeys"
Variables ¶
var PostgreSQLCreateTable []byte
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain interface { // Next for the passed key name returns an value guaranteed to be greater // than the value returned for the same key name passed at the time // of previous call of the next method or the forward method. // Next method must be thread safe. Next(ctx context.Context, key string) (value int64, err error) // Last for the passed key name returns the value returned for // the same key name passed at the time of previous call // of the next method or the forward method. // Last method must be thread safe. Last(ctx context.Context, key string) (value int64, err error) // Forward for the passed key name returns an value guaranteed // to be greater or equal to the target value and guaranteed to be greater // than the value returned for the same key name passed at the time // of previous call of the forward method or the next method. // Forward method must be thread safe. Forward(ctx context.Context, key string, target int64) (result int64, err error) // Close closes key chain. // // Close method must be thread safe. // Specific implementations may document their own behavior. Close() (err error) }
Chain is the persistence interface for the serialkey sequences.
type Local ¶
Local is the serialkeys keychain based on the local memory.
func NewLocal ¶
func NewLocal(opts ...LocalOption) *Local
NewLocal returns the serialkeys keychain based on the memory of the host where the module is running.
func (*Local) Forward ¶ added in v0.1.0
Forward for the passed key name returns an value guaranteed to be greater or equal to the target value and guaranteed to be greater than the value returned for the same key name passed at the time of previous call of the forward method or the next method. Forward method is thread safe.
func (*Local) Last ¶
Last for the passed key name returns the value returned for the same key name passed at the time of previous call of the next method or the forward method. The last method is thread safe.
type LocalConfiguration ¶
type LocalConfiguration struct {
// contains filtered or unexported fields
}
LocalConfiguration holds values changeable by options.
type LocalOption ¶
type LocalOption func(*LocalConfiguration)
LocalOption changes configuration.
func LocalWithStart ¶
func LocalWithStart(start int64) LocalOption
LocalWithStart sets the start number.
type PgxPool ¶
PgxPool is the serialkeys keychain based on the pgx pool.
func NewPgxPool ¶
func NewPgxPool(pool *pgxpool.Pool, opts ...PgxPoolOption) *PgxPool
NewPgxPool returns the serialkeys keychain based on the pgx pool.
func (*PgxPool) CreateTable ¶
CreateTable creates the PostgreSQL table if not exists. The create table method is thread safe.
func (*PgxPool) Forward ¶ added in v0.1.0
Forward for the passed key name returns an value guaranteed to be greater or equal to the target value and guaranteed to be greater than the value returned for the same key name passed at the time of previous call of the forward method or the next method. Forward method is thread safe.
func (*PgxPool) Last ¶
Last for the passed key name returns the value returned for the same key name passed at the time of previous call of the next method or the forward method. Last method must be thread safe.
func (*PgxPool) Next ¶
Next for the passed key name returns an value guaranteed to be greater than the value returned for the same key name passed at the time of previous call of the next method or the forward method. The next method is thread safe.
type PgxPoolConfiguration ¶
type PgxPoolConfiguration struct {
// contains filtered or unexported fields
}
PgxPoolConfiguration holds values changeable by options.
type PgxPoolOption ¶
type PgxPoolOption func(*PgxPoolConfiguration)
PgxPoolOption changes configuration.
func PgxPoolWithStart ¶
func PgxPoolWithStart(start int64) PgxPoolOption
PgxPoolWithStart sets the start number.
func PgxPoolWithTable ¶
func PgxPoolWithTable(table string) PgxPoolOption
PgxPoolWithTable sets the table name.
type PostgreSQL ¶
type PostgreSQL struct {
Table string
}