Package cloud.google.com/go/pubsublite/publish (v0.6.0)

Package publish contains utilities related to publishing messages.

  type 
  
 Metadata 
  
 struct 
  
 { 
  
 // The topic partition the message was published to. 
  
 Partition 
  
  int 
 
  
 // The offset the message was assigned. 
  
 Offset 
  
  int64 
 
 } 
 

Metadata holds the result of publishing a message to the Pub/Sub Lite service.

  func 
  
 ParseMetadata 
 ( 
 id 
  
  string 
 
 ) 
  
 ( 
 * 
  Metadata 
 
 , 
  
  error 
 
 ) 
 

ParseMetadata converts the ID string of a pubsub.PublishResult to Metadata.

Example: result := publisher.Publish(ctx, &pubsub.Message{Data: []byte("payload")}) id, err := result.Get(ctx) if err != nil { // TODO: Handle error. } metadata, err := publish.ParseMetadata(id) if err != nil { // TODO: Handle error. }

  func 
  
 ( 
 m 
  
 * 
  Metadata 
 
 ) 
  
 String 
 () 
  
  string 
 
 
Create a Mobile Website
View Site in Mobile | Classic
Share by: