Пример #1
0
func LoadPQueue(desc *common.ServiceDescription) (iface.ISvc, error) {
	config := &PQConfig{}
	database := db.GetDatabase()
	err := database.LoadServiceConfig(config, common.MakeServiceId(desc))
	if err != nil {
		return nil, err
	}
	pq := initPQueue(desc, config)
	return pq, nil
}
Пример #2
0
func initPQueue(desc *common.ServiceDescription, config *PQConfig) *PQueue {
	pq := PQueue{
		desc:               desc,
		config:             config,
		msgMap:             make(map[string]*PQMessage),
		availMsgs:          structs.NewActiveQueues(config.MaxPriority),
		expireHeap:         structs.NewIndexHeap(),
		inFlightHeap:       structs.NewIndexHeap(),
		database:           db.GetDatabase(),
		newMsgNotification: make(chan bool),
		msgSerialNumber:    0,
		serviceId:          common.MakeServiceId(desc),
	}

	pq.loadAllMessages()
	return &pq
}