Exemple #1
0
func NewConsumer(
	msgStore *msgstore.MessageStore,
	arguments *amqp.Table,
	cchannel ConsumerChannel,
	consumerTag string,
	exclusive bool,
	noAck bool,
	noLocal bool,
	cqueue ConsumerQueue,
	queueName string,
	prefetchSize uint32,
	prefetchCount uint16,
	localId int64,
) *Consumer {
	return &Consumer{
		msgStore:      msgStore,
		arguments:     arguments,
		cchannel:      cchannel,
		ConsumerTag:   consumerTag,
		exclusive:     exclusive,
		incoming:      make(chan bool, 1),
		noAck:         noAck,
		noLocal:       noLocal,
		cqueue:        cqueue,
		queueName:     queueName,
		prefetchSize:  prefetchSize,
		prefetchCount: prefetchCount,
		localId:       localId,
		// stats
		statConsumeOneGetOne: stats.MakeHistogram("Consume-One-Get-One"),
		statConsumeOne:       stats.MakeHistogram("Consume-One-"),
		statConsumeOneAck:    stats.MakeHistogram("Consume-One-Ack"),
		statConsumeOneSend:   stats.MakeHistogram("Consume-One-Send"),
	}
}
Exemple #2
0
func NewQueue(
	name string,
	durable bool,
	exclusive bool,
	autoDelete bool,
	arguments *amqp.Table,
	connId int64,
	msgStore *msgstore.MessageStore,
	deleteChan chan *Queue,
) *Queue {
	return &Queue{
		QueueState: gen.QueueState{
			Name:      name,
			Durable:   durable,
			Arguments: arguments,
		},
		exclusive:  exclusive,
		autoDelete: autoDelete,
		ConnId:     connId,
		msgStore:   msgStore,
		deleteChan: deleteChan,
		// Fields that aren't passed in
		statProcOne: stats.MakeHistogram("queue-proc-one"),
		queue:       list.New(),
		consumers:   make([]*consumer.Consumer, 0, 1),
		maybeReady:  make(chan bool, 1),
	}
}
Exemple #3
0
func NewMessageStore(fileName string) (*MessageStore, error) {
	db, err := bolt.Open(fileName, 0600, nil)
	if err != nil {
		return nil, err
	}
	ms := &MessageStore{
		index:        make(map[int64]*amqp.IndexMessage),
		messages:     make(map[int64]*amqp.Message),
		db:           db,
		addOps:       make(map[PersistKey]*amqp.QueueMessage),
		delOps:       make(map[PersistKey]*amqp.QueueMessage),
		deliveredOps: make(map[PersistKey]*amqp.QueueMessage),
	}
	// Stats
	ms.statAdd = stats.MakeHistogram("add-message")
	ms.statRemoveRef = stats.MakeHistogram("remove-ref")

	return ms, nil
}
Exemple #4
0
func NewChannel(id uint16, conn *AMQPConnection) *Channel {
	// Perf note: The server is significantly more performant if there's a
	// buffer for incoming, but until there are metrics available to see
	// what in particular is slow I'm leaving it as-is
	return &Channel{
		id:           id,
		server:       conn.server,
		incoming:     make(chan *amqp.WireFrame, 100),
		outgoing:     conn.outgoing,
		conn:         conn,
		flow:         true,
		state:        CH_STATE_INIT,
		txMessages:   make([]*amqp.TxMessage, 0),
		txAcks:       make([]*amqp.TxAck, 0),
		consumers:    make(map[string]*consumer.Consumer),
		awaitingAcks: make(map[uint64]amqp.UnackedMessage),
		// Stats
		statPublish:    stats.MakeHistogram("statPublish"),
		statRoute:      stats.MakeHistogram("statRoute"),
		statSendChan:   stats.MakeHistogram("statSendChan"),
		statSendEncode: stats.MakeHistogram("statSendEncode"),
	}
}
Exemple #5
0
func NewFromPersistedState(state *gen.QueueState, msgStore *msgstore.MessageStore, deleteChan chan *Queue) *Queue {
	return &Queue{
		QueueState: *state,
		exclusive:  false,
		autoDelete: false,
		ConnId:     -1,
		msgStore:   msgStore,
		deleteChan: deleteChan,
		// Fields that aren't passed in
		statProcOne: stats.MakeHistogram("queue-proc-one"),
		queue:       list.New(),
		consumers:   make([]*consumer.Consumer, 0, 1),
		maybeReady:  make(chan bool, 1),
	}
}