A connection to the Cloud Pub/Sub service to receive events.
This interface defines pure-virtual functions for each of the user-facing overload sets in Subscriber. That is, all of Subscriber's overloads will forward to the one pure-virtual function declared in this interface. This allows users to inject custom behavior (e.g., with a Google Mock object) in a Subscriber object for use in their own tests.
To create a concrete instance that connects you to the real Cloud Pub/Sub service, see MakeSubscriberConnection().
The *Params nested classes
Applications may define classes derived from SubscriberConnection, for example, because they want to mock the class. To avoid breaking all such derived classes when we change the number or type of the arguments to the member functions we define lightweight structures to pass the arguments.
Functions
virtual Subscribe(SubscribeParams)
Defines the interface for Subscriber::Subscribe(ApplicationCallback)
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["\u003cp\u003eThe page documents the \u003ccode\u003eSubscriberConnection\u003c/code\u003e class within the Google Cloud Pub/Sub C++ library, specifically version 2.13.0, with a list of previous versions available as well.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eSubscriberConnection\u003c/code\u003e class serves as an interface for connecting to the Cloud Pub/Sub service to receive events, defining virtual functions that correspond to the user-facing methods in the \u003ccode\u003eSubscriber\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eUsers can implement custom behaviors by creating classes that derive from \u003ccode\u003eSubscriberConnection\u003c/code\u003e, enabling the mocking of \u003ccode\u003eSubscriber\u003c/code\u003e objects for testing.\u003c/p\u003e\n"],["\u003cp\u003eThe interface defines functions such as \u003ccode\u003eSubscribe\u003c/code\u003e, \u003ccode\u003eExactlyOnceSubscribe\u003c/code\u003e, and \u003ccode\u003ePull\u003c/code\u003e, each with their respective parameter structures and return types, for managing the connection to the service.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eoptions()\u003c/code\u003e function is used to return the configuration settings of the object.\u003c/p\u003e\n"]]],[],null,[]]