// New returns a new AMQP publisher/subscriber.
New returns a new AMQP publisher/subscriber.
// New returns a new AMQP publisher / subscriber .
func New(cfg Config) *PubSub {
	cfg = initConfig(cfg)
	p := &PubSub{
		Config:               cfg,
		connMgr:              newConnectionMgr(amqp.ConnectionConfig{AmqpURI: cfg.URI}, cfg.MaxConnectionSubscriptions),
		amqpConfig:           newQueueConfig(cfg),
		amqpRedeliveryConfig: newRedeliveryQueueConfig(cfg),
		amqpWaitConfig:       newWaitQueueConfig(cfg),
	}
	p.Lifecycle = lifecycle.New("amqp",
		lifecycle.WithStart(p.start),
		lifecycle.WithStop(p.stop))
	p.subscriberFactory = func(conn connection) (initializingSubscriber, error) {
		return amqp.NewSubscriberWithConnection(p.amqpConfig, wmlogger.New(), conn.amqpConnection())
	}
	p.createPublisher = func(conn connection) (publisher, error) {
		return amqp.NewPublisherWithConnection(p.amqpConfig, wmlogger.New(), conn.amqpConnection())
	}
	p.redeliverySubscriberFactory = func(conn connection) (initializingSubscriber, error) {
		return amqp.NewSubscriberWithConnection(p.amqpRedeliveryConfig, wmlogger.New(), conn.amqpConnection())
	}
	p.waitSubscriberFactory = func(conn connection) (initializingSubscriber, error) {
		return amqp.NewSubscriberWithConnection(p.amqpWaitConfig, wmlogger.New(), conn.amqpConnection())
	}
	p.createWaitPublisher = func(conn connection) (publisher, error) {
		return amqp.NewPublisherWithConnection(p.amqpWaitConfig, wmlogger.New(), conn.amqpConnection())
	}
	p.Start()
	return p
}
func New ( cfg Config ) * PubSub { cfg = initConfig ( cfg ) p := & PubSub { Config : cfg , connMgr : newConnectionMgr ( amqp . ConnectionConfig { AmqpURI : cfg . URI } , cfg . MaxConnectionSubscriptions ) , amqpConfig : newQueueConfig ( cfg ) , amqpRedeliveryConfig : newRedeliveryQueueConfig ( cfg ) , amqpWaitConfig : newWaitQueueConfig ( cfg ) , } p . Lifecycle = lifecycle . New ( " " , lifecycle . WithStart ( p . start ) , lifecycle . WithStop ( p . stop ) ) p . subscriberFactory = func ( conn connection ) ( initializingSubscriber , error ) { return amqp . NewSubscriberWithConnection ( p . amqpConfig , wmlogger . New ( ) , conn . amqpConnection ( ) ) } p . createPublisher = func ( conn connection ) ( publisher , error ) { return amqp . NewPublisherWithConnection ( p . amqpConfig , wmlogger . New ( ) , conn . amqpConnection ( ) ) } p . redeliverySubscriberFactory = func ( conn connection ) ( initializingSubscriber , error ) { return amqp . NewSubscriberWithConnection ( p . amqpRedeliveryConfig , wmlogger . New ( ) , conn . amqpConnection ( ) ) } p . waitSubscriberFactory = func ( conn connection ) ( initializingSubscriber , error ) { return amqp . NewSubscriberWithConnection ( p . amqpWaitConfig , wmlogger . New ( ) , conn . amqpConnection ( ) ) } p . createWaitPublisher = func ( conn connection ) ( publisher , error ) { return amqp . NewPublisherWithConnection ( p . amqpWaitConfig , wmlogger . New ( ) , conn . amqpConnection ( ) ) } p . Start ( ) return p }
New returns a new AMQP publisher/subscriber.
New returns a new AMQP publisher / subscriber .
// Start the service immediately.