示例#1
0
func LoadAllQueues(db *bolt.DB, msgStore *msgstore.MessageStore, deleteChan chan *Queue) (map[string]*Queue, error) {
	queueStateMap, err := persist.LoadAll(db, QUEUE_BUCKET_NAME, &QueueStateFactory{})
	if err != nil {
		return nil, err
	}
	var ret = make(map[string]*Queue)
	for key, state := range queueStateMap {
		ret[key] = NewFromPersistedState(state.(*gen.QueueState), msgStore, deleteChan)
	}
	return ret, nil
}
示例#2
0
func LoadAllExchanges(db *bolt.DB, deleteChan chan *Exchange) (map[string]*Exchange, error) {
	exStateMap, err := persist.LoadAll(db, EXCHANGES_BUCKET_NAME, &ExchangeStateFactory{})
	if err != nil {
		return nil, err
	}
	var ret = make(map[string]*Exchange)
	for key, state := range exStateMap {
		ret[key] = NewFromExchangeState(state.(*gen.ExchangeState), deleteChan)
	}
	return ret, nil
}
示例#3
0
func (ms *MessageStore) LoadQueueFromDisk(queueName string) (*list.List, error) { // list[amqp.QueueMessage]
	var ret = list.New()
	qmMap, err := persist.LoadAll(ms.db, []byte(fmt.Sprintf("queue_%s", queueName)), &QueueMessageFactory{})
	if err != nil {
		return nil, err
	}
	for _, unmarshaler := range qmMap {
		var qm = unmarshaler.(*amqp.QueueMessage)
		qm.LocalId = -1
		ret.PushFront(qm)
	}
	return ret, nil
}
示例#4
0
func (ms *MessageStore) LoadMessages() error {
	// Index
	imMap, err := persist.LoadAll(ms.db, MESSAGE_INDEX_BUCKET, &IndexMessageFactory{})
	if err != nil {
		return err
	}
	for _, unmarshaler := range imMap {
		var im = unmarshaler.(*amqp.IndexMessage)
		ms.index[im.Id] = im
	}
	// Content
	// TODO: don't load all content if it won't fit in memory
	mMap, err := persist.LoadAll(ms.db, MESSAGE_CONTENT_BUCKET, &MessageContentFactory{})
	if err != nil {
		return err
	}
	for _, unmarshaler := range mMap {
		var msg = unmarshaler.(*amqp.Message)
		ms.messages[msg.Id] = msg
	}
	return nil
}
示例#5
0
func LoadAllBindings(db *bolt.DB) (map[string]*Binding, error) {
	exStateMap, err := persist.LoadAll(db, BINDINGS_BUCKET_NAME, &BindingStateFactory{})
	if err != nil {
		return nil, err
	}
	var ret = make(map[string]*Binding)
	for key, state := range exStateMap {
		var sb = state.(*gen.BindingState)
		// TODO: we don't actually know if topic is true, so this is extra work
		// for other exchange binding types
		ret[key], err = NewBinding(sb.QueueName, sb.ExchangeName, sb.Key, sb.Arguments, sb.Topic)
		if err != nil {
			return nil, err
		}
	}
	return ret, nil
}