func NewBroker(cfg *AmqpConfig) (v *broker, err error) { if cfg == nil { cfg = DefaultAmqpConfig() } v = &broker{ consumers: dingo.NewRoutines(), cfg: *cfg, } v.sender, err = newConnection(&v.cfg) if err != nil { return } v.receiver, err = newConnection(&v.cfg) if err != nil { return } // get a free channel, // either sender/receiver's channel would works ci, err := v.sender.Channel() if err != nil { return } // remember to return channel to pool defer func() { if err != nil { v.sender.ReleaseChannel(nil) } else { v.sender.ReleaseChannel(ci) } }() // init exchange err = ci.Channel.ExchangeDeclare( "dingo.x.task", // name of exchange "direct", // kind true, // durable false, // auto-delete false, // internal false, // noWait nil, // args ) if err != nil { return } v.consumerTags = make(chan int, v.receiver.maxChannel) for i := 0; i < v.receiver.maxChannel; i++ { v.consumerTags <- i } return }
func NewBroker(cfg *RedisConfig) (v *broker, err error) { if cfg == nil { cfg = DefaultRedisConfig() } v = &broker{ listeners: dingo.NewRoutines(), cfg: *cfg, } v.pool, err = newRedisPool(&v.cfg) if err != nil { return } return }
func (ts *DingoMultiAppTestSuite) SetupSuite() { ts.NotEqual(0, ts.CountOfCallers) ts.NotEqual(0, ts.CountOfWorkers) ts.eventRoutines = dingo.NewRoutines() }
func (ts *DingoSingleAppTestSuite) SetupSuite() { ts.eventRoutines = dingo.NewRoutines() }