-
Notifications
You must be signed in to change notification settings - Fork 18
feat: destgcppubsub #464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: destgcppubsub #464
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
# Conflicts: # internal/destregistry/providers/default.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new GCP Pub/Sub destination provider to the outpost project, enabling events to be published to Google Cloud Pub/Sub topics.
- Implements the complete destination provider interface for GCP Pub/Sub
- Adds comprehensive test coverage including unit tests and integration tests
- Provides development tools and documentation for testing the implementation
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
internal/destregistry/providers/destgcppubsub/destgcppubsub.go | Core provider implementation with publisher and validation logic |
internal/destregistry/providers/destgcppubsub/destgcppubsub_test.go | Unit tests for ComputeTarget and Validate methods |
internal/destregistry/providers/destgcppubsub/destgcppubsub_publish_test.go | Integration tests with emulator support |
internal/destregistry/providers/default.go | Registers the new GCP Pub/Sub provider |
internal/destregistry/metadata/providers/gcp_pubsub/metadata.json | Configuration metadata for the provider |
internal/destregistry/metadata/providers/gcp_pubsub/instructions.md | Placeholder instructions file |
contributing/destinations/gcp_pubsub/test-destination.md | Testing guide with GCP setup commands |
contributing/destinations/gcp_pubsub/configuration.md | Implementation decisions and configuration options documentation |
cmd/destinations/gcppubsub/main.go | Standalone consumer tool for testing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
internal/destregistry/metadata/providers/gcp_pubsub/instructions.md
Outdated
Show resolved
Hide resolved
|
||
For the Outpost destination config: | ||
- project_id: "outpost-pubsub-test" | ||
- topic: "outpost-test-topic" |
Copilot
AI
Oct 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The topic name in the configuration example doesn't match the topic created in step 8. It should be 'outpost-destination-test' to match the created topic.
- topic: "outpost-test-topic" | |
- topic: "outpost-destination-test" |
Copilot uses AI. Check for mistakes.
PR Review: GCP Pub/Sub Destination ImplementationThis PR adds support for Google Cloud Pub/Sub as a destination provider. Overall this is a solid implementation with good documentation and test coverage. Critical Issues1. Missing BasePublisher initialization pattern (destgcppubsub.go:86) 2. Missing basePublisherOpts parameter (default.go:105) 3. Missing Preprocess implementation Medium Priority Issues4. Potential resource leak (destgcppubsub.go:197-199) 5. Incomplete instructions.md 6. Missing icon in metadata.json Minor Issues
Security ReviewNo security concerns. Credentials properly handled, emulator mode appropriately uses insecure credentials only when endpoint is set. Strengths
SummaryMust fix before merge:
Should fix: Great work on testing and documentation! |
@alexluong - massive delay on testing this and creating instructions - sorry. However, finally got around to it and all good. Claude has indicated there are some things to review and I think the base publisher update needs added to the GCP Pub/Sub destinations, too #464 (comment) |
Pull Request Review: GCP Pub/Sub DestinationSummaryThis PR adds GCP Pub/Sub as a new destination provider for Outpost. The implementation is well-structured and follows the existing patterns in the codebase. Overall, this is a solid implementation with good test coverage and comprehensive documentation. ✅ StrengthsCode Quality
Documentation
Testing
🔧 Issues & Recommendations1.
|
@leggetter no worries, thanks for checking it out. Yes I've been following Claude's suggestions above and they're valid, will shift to them now if you're still around to give this another go. |
This brings the GCP Pub/Sub provider in line with other destination providers by accepting basePublisherOpts, allowing configuration of options like millisecond timestamp support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
The publisher now uses d.BaseProvider.NewPublisher() instead of creating a new BasePublisher struct. This ensures the publisher receives properly configured options from basePublisherOpts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This resolves the TODO comment and ensures GCP Pub/Sub receives the same base publisher configuration as other destination providers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
The GCP Pub/Sub client is thread-safe, so the mutex was unnecessary. Removed the mu field and lock/unlock calls in Close(). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add explicit no-op Preprocess() method to match the pattern used by other destination providers like Azure Service Bus. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Update error message to use Google's official branding with capital P and S. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add fmt.Printf to log errors in the consume loop for easier debugging during test failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add official GCP Pub/Sub icon for better UI consistency. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Update the destination config to use 'outpost-destination-test' to match the topic created in step 1. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
PR Review: GCP Pub/Sub Destination ImplementationSummaryThis PR adds GCP Pub/Sub as a new destination provider for Outpost. The implementation follows established patterns from other providers (AWS SQS, Azure Service Bus) and includes comprehensive tests, documentation, and metadata configuration. Code Quality ✅Strengths
Code Style
Potential Issues 🔍1. Resource Leak Risk in Publisher Creation (Medium Priority)Location: The client, err := pubsub.NewClient(ctx, cfg.ProjectID, opts...)
if err != nil {
return nil, fmt.Errorf("failed to create Pub/Sub client: %w", err)
}
topic := client.Topic(cfg.Topic)
// No existence check here - publisher created immediately Recommendation: Consider adding optional topic validation or ensure the client is closed if subsequent operations fail. Alternatively, document that topic must exist before creating destination. 2. Missing Context Timeout in Close Method (Low Priority)Location: The func (pub *GCPPubSubPublisher) Close() error {
pub.BasePublisher.StartClose()
if pub.topic != nil {
pub.topic.Stop()
}
if pub.client != nil {
return pub.client.Close() // No timeout
}
return nil
} Compare with Azure Service Bus implementation which uses a 5-second timeout: ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if p.client != nil {
if err := p.client.Close(ctx); err != nil {
return err
}
} Recommendation: Add a timeout context for graceful shutdown. 3. Validation Gap (Low Priority)Location: The
While Google SDK will catch these at runtime, early validation would provide better UX. Recommendation: Consider adding basic JSON validation for service account and GCP resource name validation. Performance Considerations ⚡1. Synchronous PublishingLocation: result := pub.topic.Publish(ctx, msg)
messageID, err := result.Get(ctx) // Blocks until published This is synchronous and blocks until acknowledgment. The GCP SDK supports batching and async publishing through Observation: This matches the pattern in other providers and is appropriate for reliability. However, for high-throughput scenarios, consider documenting potential performance optimizations (see 2. Topic Object Reuse ✅Good: The publisher reuses the Security Concerns 🔒1. Credentials Handling ✅
2. Insecure Credentials for Emulator ✅if cfg.Endpoint != "" {
opts = append(opts,
option.WithEndpoint(cfg.Endpoint),
option.WithoutAuthentication(),
option.WithGRPCDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())),
)
} This is correct - insecure credentials should only be used with custom endpoints (emulator). Minor concern: Consider adding a warning log when using insecure mode to prevent accidental production use. Test Coverage ✅Excellent Coverage
Minor Gap
Recommendation: Add a test verifying proper resource cleanup. Documentation 📚Strengths
Minor Issues
Additional Observations1. Error Messages ✅Error messages are descriptive and include context: return nil, destregistry.NewErrDestinationPublishAttempt(err, "gcp_pubsub", map[string]interface{}{
"error": "publish_failed",
"project": pub.projectID,
"topic": pub.topic.ID(),
"message": err.Error(),
}) 2. Metadata Consistency ✅The metadata structure matches other providers perfectly. 3. ComputeTarget Implementation ✅Generates useful console URLs for easy navigation to GCP resources. Recommendations SummaryHigh PriorityNone Medium Priority
Low Priority
Conclusion ✅Recommendation: Approve with minor suggestions This is a high-quality implementation that:
The suggested improvements are minor and don't block merging. Great work! 🎉 Review generated by Claude Code |
Review of PR #464: feat: destgcppubsub OverviewThis PR adds GCP Pub/Sub as a new destination provider. The implementation is comprehensive, well-structured, and follows existing patterns. This is a high-quality contribution ready for merge with minor optional suggestions. StrengthsCode Quality
Test Coverage
Documentation
Developer Experience
SuggestionsMedium Priority
Low Priority
SecuritySecure Practices:
PerformanceGood Practices:
Future enhancements documented in configuration.md:
CompletenessPer contributing/destinations.md:
Files ChangedTotal: +1447 lines, 9 files destgcppubsub.go (204) - Excellent RecommendationAPPROVE - Ready to merge Implementation is:
Optional Before Merge:
Follow-up PRs:
Great Work!High-quality contribution with excellent architecture understanding. The configuration.md showing design trade-offs is valuable for maintainers. Documentation and dev experience (emulator, tooling) are particularly commendable. Reviewed by: Claude Code |
Add nil basePublisherOpts parameter to all test calls to match the updated New() function signature. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
PR Review: GCP Pub/Sub Destination ImplementationSummaryThis PR adds comprehensive support for GCP Pub/Sub as a destination provider. The implementation follows established patterns from other destination providers (Azure Service Bus, AWS SQS) and includes proper documentation, testing, and infrastructure. ✅ StrengthsCode Quality
Documentation
Testing
Features
🔍 Areas for Improvement1. Error Context in Close() Method (Minor)Location: The func (pub *GCPPubSubPublisher) Close() error {
pub.BasePublisher.StartClose()
if pub.topic != nil {
pub.topic.Stop()
}
if pub.client != nil {
return pub.client.Close() // Error lacks context
}
return nil
} Recommendation: Add error wrapping for better debugging: if pub.client != nil {
if err := pub.client.Close(); err != nil {
return fmt.Errorf("failed to close GCP Pub/Sub client: %w", err)
}
} 2. Topic Name Inconsistency in DocumentationLocation: This was fixed in commit 3. Missing Timeout on Close() Operation (Minor)Location: Unlike Azure Service Bus which uses a timeout context for cleanup, the GCP Pub/Sub implementation doesn't set a timeout: // Azure Service Bus pattern:
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel() Recommendation: Consider adding a timeout to prevent hanging on shutdown: func (pub *GCPPubSubPublisher) Close() error {
pub.BasePublisher.StartClose()
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if pub.topic != nil {
pub.topic.Stop()
}
if pub.client != nil {
if err := pub.client.Close(); err != nil {
return fmt.Errorf("failed to close GCP Pub/Sub client: %w", err)
}
}
return nil
} Note: The GCP SDK's 4. Consider Validation of JSON Structure (Enhancement)Location: The test notes that JSON validation was removed: {
name: "invalid JSON in service_account_json",
credentials: map[string]string{
"service_account_json": "not-valid-json",
},
wantErr: false, // We don't validate JSON structure anymore, Google SDK will handle it
} While deferring to the Google SDK is reasonable, consider whether early JSON validation would provide better user experience:
Decision: Current approach is acceptable, but could enhance UX with basic JSON validation. 🚀 Performance ConsiderationsSynchronous PublishingThe current implementation waits for each publish acknowledgment ( Potential optimization (documented in topic.PublishSettings = pubsub.PublishSettings{
DelayThreshold: 100 * time.Millisecond,
CountThreshold: 100,
ByteThreshold: 1e6,
} This is appropriately documented as a future enhancement rather than current implementation - good prioritization. Topic Existence ValidationThe code notes (in 🔒 Security Review✅ Credentials Handling
✅ Emulator Configuration
|
@leggetter ready for another round of review |
PR Review: GCP Pub/Sub Destination ImplementationOverviewThis PR adds support for GCP Pub/Sub as a destination provider. The implementation follows the established patterns from other providers and includes comprehensive testing and documentation. Overall, this is a solid implementation with good test coverage. ✅ Strengths
🐛 Potential Issues1. Missing Preprocess Method Implementation (destgcppubsub.go:115-118)The 2. No Topic Existence Validation (destgcppubsub.go:45-51)The func (d *GCPPubSubDestination) Validate(ctx context.Context, destination *models.Destination) error {
cfg, creds, err := d.resolveMetadata(ctx, destination)
if err != nil {
return err
}
// Optional: Verify topic exists (if not using emulator)
if cfg.Endpoint == "" {
// Create temporary client to validate
// This would catch config errors early
}
return nil
} 3. Incomplete URL Truncation in Diff (internal/destregistry/providers/default.go:109)The diff shows the registration line is cut off: 4. Synchronous Publishing May Impact Performance (destgcppubsub.go:163-166)The implementation uses synchronous publishing with 🔒 Security Considerations✅ Good Security Practices
|
No description provided.