MCPcopy Create free account
hub / github.com/google/go-cloud / CreateSubscription

Method CreateSubscription

pubsub/rabbitpubsub/rabbit_test.go:135–149  ·  view source on GitHub ↗
(_ context.Context, dt driver.Topic, testName string)

Source from the content-addressed store, hash-verified

133}
134
135func (h *harness) CreateSubscription(_ context.Context, dt driver.Topic, testName string) (ds driver.Subscription, cleanup func(), err error) {
136 queue := fmt.Sprintf("%s-subscription-%d", testName, atomic.AddUint32(&h.numSubs, 1))
137 if err := bindQueue(h.conn, queue, dt.(*topic).exchange); err != nil {
138 return nil, nil, err
139 }
140 cleanup = func() {
141 ch, err := h.conn.Channel()
142 if err != nil {
143 panic(err)
144 }
145 ch.QueueDelete(queue)
146 }
147 ds = newSubscription(h.conn, queue, nil)
148 return ds, cleanup, nil
149}
150
151func (h *harness) MakeNonexistentSubscription(_ context.Context) (driver.Subscription, func(), error) {
152 return newSubscription(h.conn, "nonexistent-subscription", nil), func() {}, nil

Callers 2

BenchmarkRabbitFunction · 0.95

Calls 4

bindQueueFunction · 0.85
newSubscriptionFunction · 0.70
ChannelMethod · 0.65
QueueDeleteMethod · 0.65

Tested by

no test coverage detected