Documentation ¶
Index ¶
Constants ¶
const ( VERSION = "1.0.1" AttemptName = "amqp-attempt" DefaultExchange = "exchange" NotFoundIndex = -1 DefaultAttempt int32 = 1 // default exec times ErrDelay = 60 // default exec queue fail push delay time,unit second DeadLetterExchange = "x-dead-letter-exchange" DeadLetterRoutingKey = "x-dead-letter-routing-key" DelayKey = "amqp-delay" TtrKey = "amqp-ttr" )
Variables ¶
var ( Config *config RabbitmqConfig = rabbitmqConfig{} )
var Consumer = consumer{/* contains filtered or unexported fields */}
var Producer = producer{/* contains filtered or unexported fields */}
var Util = util{}
Functions ¶
func HeartBeater ¶
HeartBeater is a convenience function for add singleton mode job.
Types ¶
type Pool ¶
type Pool struct { TTL time.Duration // Time To Live for pool items. NewFunc func() (interface{}, error) // Callback function to create pool item. // ExpireFunc is the for expired items destruction. // This function needs to be defined when the pool items // need to perform additional destruction operations. // Eg: net.Conn, os.File, etc. ExpireFunc func(interface{}) // contains filtered or unexported fields }
func NewPool ¶
func NewPool(ttl time.Duration, newFunc NewFunc, expireFunc ...ExpireFunc) *Pool
NewPool creates and returns a new object pool. To ensure execution efficiency, the expiration time cannot be modified once it is set.
Note the expiration logic: ttl = 0 : not expired; ttl < 0 : immediate expired after use; ttl > 0 : timeout expired;
func (*Pool) Clear ¶
func (p *Pool) Clear()
Clear clears pool, which means it will remove all items from pool.
func (*Pool) Close ¶
func (p *Pool) Close()
Close closes the pool. If `p` has ExpireFunc, then it automatically closes all items using this function before it's closed. Commonly you do not need to call this function manually.
func (*Pool) Get ¶
Get picks and returns an item from pool. If the pool is empty and NewFunc is defined, it creates and returns one from NewFunc.
func (*Pool) TimestampMilli ¶
TimestampMilli returns the timestamp in milliseconds.