Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ roundTripper, err := auth.DefaultAuth(&config.Configuration{
ServiceAccountKeyPath: "./service-account-key.json",
})
if err != nil {
log.Printf("Error creating authentication token: %v", err)
log.Fatalf("Error creating authentication token: %v", err)
}

publisher := pubsub.NewPublisher(topicID,
Expand Down
5 changes: 2 additions & 3 deletions example/example_publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ import (

//nolint:all
func publish() {

// Authentication with STACKIT SDK - Returns a Round-Tripper
rt, err := auth.DefaultAuth(&config.Configuration{
ServiceAccountKeyPath: "./service-account-key.json",
})
if err != nil {
log.Printf("Error creating authentication token: %v", err)
log.Fatalf("Error creating authentication token: %v", err)
}

// Setup your Topic ID
Expand All @@ -39,7 +38,7 @@ func publish() {
message,
)
if err != nil {
log.Printf("Error publishing message: %v", err)
log.Fatalf("Error publishing message: %v", err)
}

log.Print("Successfully published messages")
Expand Down
14 changes: 11 additions & 3 deletions example/example_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ import (

//nolint:all
func pull() {

// Authentication with STACKIT SDK - Returns a Round-Tripper
rt, err := auth.DefaultAuth(&config.Configuration{
ServiceAccountKeyPath: "./service-account-key.json",
})
if err != nil {
log.Printf("Error creating authentication token: %v", err)
log.Fatalf("Error creating authentication token: %v", err)
}

// Setup your TopicID and Subscription ID
Expand All @@ -33,15 +32,24 @@ func pull() {
)

// Pull messages via subscription
pulledMessages, _ := subscriber.Pull(context.Background(), pubsub.WithMaxMessages(10))
pulledMessages, err := subscriber.Pull(context.Background(), pubsub.WithMaxMessages(10))
if err != nil {
log.Fatalf("Error pulling messages: %v", err)
}

log.Printf("Successfully pulled message: %v", pulledMessages)

// Get your AckIDs and acknowledge them
ackIDs := pulledMessages.GetAckIDs()
err = subscriber.Ack(context.Background(), ackIDs)
if err != nil {
log.Fatalf("Error ack ids: %v", err)
}

// Get your NackIDs and not acknowledge them
nackIDs := pulledMessages.GetAckIDs()
err = subscriber.Nack(context.Background(), nackIDs)
if err != nil {
log.Fatalf("Error nack ids: %v", err)
}
}
7 changes: 4 additions & 3 deletions example/example_purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ import (

//nolint:all
func purge() {

// Authentication with STACKIT SDK - Returns a Round-Tripper
rt, err := auth.DefaultAuth(&config.Configuration{
ServiceAccountKeyPath: "./service-account-key.json",
})
if err != nil {
log.Printf("Error creating authentication token: %v", err)
log.Fatalf("Error creating authentication token: %v", err)
}

// Setup your TopicID and Subscription ID
Expand All @@ -31,5 +30,7 @@ func purge() {
)

err = publisher.Purge(context.Background())

if err != nil {
log.Fatalf("Error purging topic: %v", err)
}
}
Loading