PHP 클래스 Google\Cloud\PubSub\Subscription

Example: Create subscription through a topic use Google\Cloud\ServiceBuilder; $cloud = new ServiceBuilder(); $pubsub = $cloud->pubsub(); $topic = $pubsub->topic('my-topic-name'); $subscription = $topic->subscription('my-new-subscription'); Create subscription through PubSubClient use Google\Cloud\PubSub\PubSubClient; $pubsub = new PubSubClient([ 'projectId' => 'my-awesome-project' ]); $subscription = $pubsub->subscription( 'my-new-subscription', 'my-topic-name' );
상속: use trait ResourceNameTrait
파일 보기 프로젝트 열기: GoogleCloudPlatform/gcloud-php 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$connection Google\Cloud\PubSub\Connection\ConnectionInterface

공개 메소드들

메소드 설명
__construct ( Google\Cloud\PubSub\Connection\ConnectionInterface $connection, string $projectId, string $name, string $topicName, boolean $encode, array $info = null ) Create a Subscription.
__debugInfo ( ) : array Present a nicer debug result to people using php 5.6 or greater.
acknowledge ( Message $message, array $options = [] ) : void Acknowledge receipt of a message.
acknowledgeBatch ( array $messages, array $options = [] ) : void Acknowledge receipt of multiple messages at once.
create ( array $options = [] ) : array Execute a service request creating the subscription.
delete ( array $options = [] ) : void Delete a subscription
exists ( array $options = [] ) : boolean Check if a subscription exists.
iam ( ) : Iam Manage the IAM policy for the current Subscription.
info ( array $options = [] ) : array Get info on a subscription
modifyAckDeadline ( Message $message, integer $seconds, array $options = [] ) : void Set the acknowledge deadline for a single ackId.
modifyAckDeadlineBatch ( array $messages, integer $seconds, array $options = [] ) : void Set the acknowledge deadline for multiple ackIds.
modifyPushConfig ( array $pushConfig, array $options = [] ) : void Set the push config for the subscription
name ( ) : string Get the subscription name
pull ( array $options = [] ) : Generator Retrieve new messages from the topic.
reload ( array $options = [] ) : array Retrieve info on a subscription from the API.

비공개 메소드들

메소드 설명
getMessageAckIds ( array $messages ) : array Get a list of ackIds from a list of Message objects.

메소드 상세

__construct() 공개 메소드

The idiomatic way to use this class is through the PubSubClient or Topic, but you can instantiate it directly as well.
public __construct ( Google\Cloud\PubSub\Connection\ConnectionInterface $connection, string $projectId, string $name, string $topicName, boolean $encode, array $info = null )
$connection Google\Cloud\PubSub\Connection\ConnectionInterface The service connection object
$projectId string The current project
$name string The subscription name
$topicName string The topic name the subscription is attached to
$encode boolean Whether messages are encrypted or not.
$info array [optional] Subscription info. Used to pre-populate the object.

__debugInfo() 공개 메소드

Present a nicer debug result to people using php 5.6 or greater.
public __debugInfo ( ) : array
리턴 array

acknowledge() 공개 메소드

Use {@see \Google\Cloud\PubSub\Subscription::acknowledgeBatch()} to acknowledge multiple messages at once. Example: $messages = $subscription->pull(); $messagesArray = iterator_to_array($messages); $subscription->acknowledge($messagesArray[0]);
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/acknowledge Acknowledge Message
public acknowledge ( Message $message, array $options = [] ) : void
$message Message A message object.
$options array [optional] Configuration Options
리턴 void

acknowledgeBatch() 공개 메소드

Use {@see \Google\Cloud\PubSub\Subscription::acknowledge()} to acknowledge a single message. Example: $messages = $subscription->pull(); $messagesArray = iterator_to_array($messages); $subscription->acknowledgeBatch($messagesArray);
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/acknowledge Acknowledge Message
public acknowledgeBatch ( array $messages, array $options = [] ) : void
$messages array An array of messages
$options array Configuration Options
리턴 void

create() 공개 메소드

The suggested way of creating a subscription is by calling through {@see \Google\Cloud\PubSub\Topic::subscribe()} or {@see \Google\Cloud\PubSub\Topic::subscription()}. Returns subscription info in the format detailed in the documentation for a subscription. **NOTE: Some methods of instantiation of a Subscription do not supply a topic name. The topic name is required to create a subscription.** Example: $topic = $pubsub->topic('my-new-topic'); $subscription = $topic->subscription('my-new-subscription'); $result = $subscription->create();
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/create Create Subscription
public create ( array $options = [] ) : array
$options array [optional] { Configuration Options @type int $ackDeadlineSeconds This value is the maximum time after a subscriber receives a message before the subscriber should acknowledge the message. **Defaults to** `10`. @type array $pushConfig See {@see \Google\Cloud\PubSub\Subscription::modifyPushConfig()} or [PushConfig](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions#PushConfig) for usage. }
리턴 array An array of subscription info

delete() 공개 메소드

Example: $subscription->delete();
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/delete Delete Subscription
public delete ( array $options = [] ) : void
$options array [optional] Configuration Options.
리턴 void

exists() 공개 메소드

Service errors will NOT bubble up from this method. It will always return a boolean value. If you want to check for errors, use {@see \Google\Cloud\PubSub\Subscription::info()}. If you need to re-check the existence of a subscription that is already downloaded, call {@see \Google\Cloud\PubSub\Subscription::reload()} first to refresh the cached information. Example: if ($subscription->exists()) { echo 'Subscription exists!'; }
public exists ( array $options = [] ) : boolean
$options array [optional] Configuration Options
리턴 boolean

iam() 공개 메소드

Example: $iam = $subscription->iam();
또한 보기: https://cloud.google.com/pubsub/access_control PubSub Access Control Documentation
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/getIamPolicy Get Subscription IAM Policy
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/setIamPolicy Set Subscription IAM Policy
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/testIamPermissions Test Subscription Permissions
public iam ( ) : Iam
리턴 Google\Cloud\Iam\Iam

info() 공개 메소드

If the info is already cached on the object, it will return that result. To fetch a fresh result, use {@see \Google\Cloud\PubSub\Subscription::reload()}. Example: $info = $subscription->info(); echo $info['name']; // projects/my-awesome-project/subscriptions/my-new-subscription
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/get Get Subscription
public info ( array $options = [] ) : array
$options array [optional] Configuration Options
리턴 array Subscription data

modifyAckDeadline() 공개 메소드

Use {@see \Google\Cloud\PubSub\Subscription::modifyAckDeadlineBatch()} to modify the ack deadline for multiple messages at once. Example: $messages = $subscription->pull(); foreach ($messages as $message) { $subscription->modifyAckDeadline($message, 3); sleep(2); Now we'll acknowledge! $subscription->acknowledge($message); break; }
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/modifyAckDeadline Modify Ack Deadline
public modifyAckDeadline ( Message $message, integer $seconds, array $options = [] ) : void
$message Message A message object
$seconds integer The new ack deadline with respect to the time this request was sent to the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack deadline will expire 10 seconds after the ModifyAckDeadline call was made. Specifying zero may immediately make the message available for another pull request.
$options array [optional] Configuration Options
리턴 void

modifyAckDeadlineBatch() 공개 메소드

Use {@see \Google\Cloud\PubSub\Subscription::modifyAckDeadline()} to modify the ack deadline for a single message. Example: $messages = $subscription->pull(); $messagesArray = iterator_to_array($messages); Set the ack deadline to a minute and a half from now for every message $subscription->modifyAckDeadlineBatch($messagesArray, 3); Delay execution, or make a sandwich or something. sleep(2); Now we'll acknowledge $subscription->acknowledge($messagesArray);
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/modifyAckDeadline Modify Ack Deadline
public modifyAckDeadlineBatch ( array $messages, integer $seconds, array $options = [] ) : void
$messages array An array of messages
$seconds integer The new ack deadline with respect to the time this request was sent to the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack deadline will expire 10 seconds after the ModifyAckDeadline call was made. Specifying zero may immediately make the message available for another pull request.
$options array [optional] Configuration Options
리턴 void

modifyPushConfig() 공개 메소드

Example: $subscription->modifyPushConfig([ 'pushEndpoint' => 'https://www.example.com/foo/bar' ]);
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/modifyPushConfig Modify Push Config
public modifyPushConfig ( array $pushConfig, array $options = [] ) : void
$pushConfig array { Push delivery configuration. See [PushConfig](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions#PushConfig) for more details. @type string $pushEndpoint A URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might use "https://example.com/push". @type array $attributes Endpoint configuration attributes. }
$options array [optional] Configuration Options
리턴 void

name() 공개 메소드

Example: echo $subscription->name();
public name ( ) : string
리턴 string

pull() 공개 메소드

Example: $messages = $subscription->pull(); foreach ($messages as $message) { echo $message->data(); }
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/pull Pull Subscriptions
public pull ( array $options = [] ) : Generator
$options array [optional] { Configuration Options @type bool $returnImmediately If set, the system will respond immediately, even if no messages are available. Otherwise, wait until new messages are available. @type int $maxMessages Limit the amount of messages pulled. }
리턴 Generator

reload() 공개 메소드

To use the previously cached result (if it exists), use {@see \Subscription::info()}. Example: $subscription->reload(); $info = $subscription->info(); echo $info['name']; // projects/my-awesome-project/subscriptions/my-new-subscription
또한 보기: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/get Get Subscription
public reload ( array $options = [] ) : array
$options array [optional] Configuration Options
리턴 array Subscription data

프로퍼티 상세

$connection 보호되어 있는 프로퍼티

protected ConnectionInterface,Google\Cloud\PubSub\Connection $connection
리턴 Google\Cloud\PubSub\Connection\ConnectionInterface