示例#1
0
func (q *Queue) DepersistBoltTx(tx *bolt.Tx) error {
	bucket, err := tx.CreateBucketIfNotExists(QUEUE_BUCKET_NAME)
	if err != nil {
		return fmt.Errorf("create bucket: %s", err)
	}
	return persist.DepersistOneBoltTx(bucket, q.Name)
}
示例#2
0
func (binding *Binding) DepersistBoltTx(tx *bolt.Tx) error {
	bucket, err := tx.CreateBucketIfNotExists(BINDINGS_BUCKET_NAME)
	if err != nil { // pragma: nocover
		// If we're hitting this it means the disk is full, the db is readonly,
		// or something else has gone irrecoverably wrong
		panic(fmt.Sprintf("create bucket: %s", err))
	}
	return persist.DepersistOneBoltTx(bucket, string(binding.Id))
}
示例#3
0
func (exchange *Exchange) Depersist(db *bolt.DB) error {
	return db.Update(func(tx *bolt.Tx) error {
		bucket := tx.Bucket(EXCHANGES_BUCKET_NAME)
		if bucket == nil {
			return fmt.Errorf("Bucket not found: '%s'", bucket)
		}
		for _, binding := range exchange.bindings {
			if err := binding.DepersistBoltTx(tx); err != nil { // pragma: nocover
				return err
			}
		}
		return persist.DepersistOneBoltTx(bucket, exchange.Name)
	})
}