Package publishing is an auto-generated package for the Eventarc Publishing API.
NOTE: This package is in beta. It is not stable, and may be subject to changes.
Example usage
To get started with this package, create a client.
ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := publishing.NewPublisherClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close()
The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.
Using the Client
The following is an example of making an API call with the newly created client.
ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := publishing.NewPublisherClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &publishingpb.PublishChannelConnectionEventsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/eventarc/publishing/apiv1/publishingpb#PublishChannelConnectionEventsRequest. } resp, err := c.PublishChannelConnectionEvents(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context
The ctx passed to NewPublisherClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
For information about setting deadlines, reusing contexts, and more please visit https://pkg.go.dev/cloud.google.com/go.
Functions
func DefaultAuthScopes
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
PublisherCallOptions
type PublisherCallOptions struct {
PublishChannelConnectionEvents []gax.CallOption
PublishEvents []gax.CallOption
}
PublisherCallOptions contains the retry settings for each method of PublisherClient.
PublisherClient
type PublisherClient struct {
// The call options for this service.
CallOptions *PublisherCallOptions
// contains filtered or unexported fields
}
PublisherClient is a client for interacting with Eventarc Publishing API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Eventarc processes events generated by an event provider and delivers them to a subscriber.
An event provider is a software-as-a-service (SaaS) system or product that can generate and deliver events through Eventarc.
A third-party event provider is an event provider from outside of Google.
A partner is a third-party event provider that is integrated with Eventarc.
A subscriber is a GCP customer interested in receiving events.
Channel is a first-class Eventarc resource that is created and managed by the subscriber in their GCP project. A Channel represents a subscriber’s intent to receive events from an event provider. A Channel is associated with exactly one event provider.
ChannelConnection is a first-class Eventarc resource that is created and managed by the partner in their GCP project. A ChannelConnection represents a connection between a partner and a subscriber’s Channel. A ChannelConnection has a one-to-one mapping with a Channel.
Publisher allows an event provider to publish events to Eventarc.
func NewPublisherClient
func NewPublisherClient(ctx context.Context, opts ...option.ClientOption) (*PublisherClient, error)
NewPublisherClient creates a new publisher client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Eventarc processes events generated by an event provider and delivers them to a subscriber.
An event provider is a software-as-a-service (SaaS) system or product that can generate and deliver events through Eventarc.
A third-party event provider is an event provider from outside of Google.
A partner is a third-party event provider that is integrated with Eventarc.
A subscriber is a GCP customer interested in receiving events.
Channel is a first-class Eventarc resource that is created and managed by the subscriber in their GCP project. A Channel represents a subscriber’s intent to receive events from an event provider. A Channel is associated with exactly one event provider.
ChannelConnection is a first-class Eventarc resource that is created and managed by the partner in their GCP project. A ChannelConnection represents a connection between a partner and a subscriber’s Channel. A ChannelConnection has a one-to-one mapping with a Channel.
Publisher allows an event provider to publish events to Eventarc.
Example
package main
import (
"context"
publishing "cloud.google.com/go/eventarc/publishing/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := publishing.NewPublisherClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*PublisherClient) Close
func (c *PublisherClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*PublisherClient) Connection (deprecated)
func (c *PublisherClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*PublisherClient) PublishChannelConnectionEvents
func (c *PublisherClient) PublishChannelConnectionEvents(ctx context.Context, req *publishingpb.PublishChannelConnectionEventsRequest, opts ...gax.CallOption) (*publishingpb.PublishChannelConnectionEventsResponse, error)
PublishChannelConnectionEvents publish events to a ChannelConnection in a partner’s project.
Example
package main
import (
"context"
publishing "cloud.google.com/go/eventarc/publishing/apiv1"
publishingpb "cloud.google.com/go/eventarc/publishing/apiv1/publishingpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := publishing.NewPublisherClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &publishingpb.PublishChannelConnectionEventsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/eventarc/publishing/apiv1/publishingpb#PublishChannelConnectionEventsRequest.
}
resp, err := c.PublishChannelConnectionEvents(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*PublisherClient) PublishEvents
func (c *PublisherClient) PublishEvents(ctx context.Context, req *publishingpb.PublishEventsRequest, opts ...gax.CallOption) (*publishingpb.PublishEventsResponse, error)
PublishEvents publish events to a subscriber’s channel.
Example
package main
import (
"context"
publishing "cloud.google.com/go/eventarc/publishing/apiv1"
publishingpb "cloud.google.com/go/eventarc/publishing/apiv1/publishingpb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := publishing.NewPublisherClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &publishingpb.PublishEventsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/eventarc/publishing/apiv1/publishingpb#PublishEventsRequest.
}
resp, err := c.PublishEvents(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}