breaking changes to pubsub

259 views
Skip to first unread message

Jonathan Amsterdam

unread,
Mar 10, 2017, 11:45:01 AM3/10/17
to google-api-...@googlegroups.com
As we our move our Cloud Pub/Sub client toward beta, we're making a couple of fundamental changes. Both are driven by our desire to make the client not merely high-performance, but high-performance by default. 

If you don't want these changes to affect you until you're ready to deal with them, we suggest vendoring the cloud.google.com/go/pubsub package, perhaps with an existing package management tool. We've provided the repo tag v0.7.0 to support tools that accept tags. Vendoring to that tag (or the hash of master as of right now, 2e6a95edb1071d750f6d7db777bf66cd2997af6c) will isolate your code from these changes.

The first change, which will be submitted momentarily, alters how publishing works. Instead of Publish accepting a list of messages and synchronously calling the service, it will accept only a single message, queuing it for an asynchronous call. The client batches messages and sends them to the service concurrently, resulting in high throughput. 

Instead of writing

   messageIDs, err := topic.Publish(ctx, msg1, msg2)

you will write

   res1 := topic.Publish(ctx, msg1)
   res2 := topic.Publish(ctx, msg2)

Neither of these two Publish calls will block. The return value of Publish acts like a future: call Get on it to block until the message is sent.

The second change will affect subscriptions. Instead of Subscription.Pull returning an iterator, it will accept a callback. We'll have more details when that change is about to land.
Reply all
Reply to author
Forward
0 new messages