diff --git a/README.md b/README.md index c53a4ff..9d8fafc 100644 --- a/README.md +++ b/README.md @@ -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, diff --git a/example/example_publish.go b/example/example_publish.go index edd52cc..11fe16e 100644 --- a/example/example_publish.go +++ b/example/example_publish.go @@ -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 @@ -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") diff --git a/example/example_pull.go b/example/example_pull.go index 0a331e5..fbe2d88 100644 --- a/example/example_pull.go +++ b/example/example_pull.go @@ -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 @@ -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) + } } diff --git a/example/example_purge.go b/example/example_purge.go index 221e96e..c38cfe4 100644 --- a/example/example_purge.go +++ b/example/example_purge.go @@ -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 @@ -31,5 +30,7 @@ func purge() { ) err = publisher.Purge(context.Background()) - + if err != nil { + log.Fatalf("Error purging topic: %v", err) + } }