Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 31, 2025

PR #12 had merge conflicts with the root branch due to divergent PubSub implementations. The feature branch introduced an agnostic PubSub interface supporting both In-Memory and GCP backends, while root had a pattern-based implementation.

Resolution Strategy

  • README.md: Preserved agnostic PubSub documentation (In-Memory & GCP), batch operations, and metrics sections. Incorporated improved documentation structure from root (Contributing, Acknowledgments, Support sections)
  • go.mod/go.sum: Kept feature branch versions (Go 1.24.0 + GCP PubSub dependencies)
  • main.go: Retained agnostic PubSub demonstration code
  • memorystore/memorystore.go, memorystore/pubsub.go: Preserved PubSubClient interface and implementations

The merged codebase maintains the advanced feature set while improving documentation completeness.

// Agnostic interface preserved
type PubSubClient interface {
    Subscribe(topic string) (<-chan []byte, error)
    Publish(topic string, message []byte) error
    Unsubscribe(topic string) error
    Close() error
}

// Auto-selects implementation based on config
config := Config{GCPProjectID: "my-project"} // Uses GCP
store := NewMemoryStoreWithConfig(config)

// Or environment variable
// GOOGLE_CLOUD_PROJECT=my-project -> GCP PubSub
// (unset) -> In-Memory PubSub

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

google-labs-jules bot and others added 5 commits December 31, 2025 05:21
Added SetMulti and GetMulti methods for efficient batch operations.
Added StoreMetrics struct and GetMetrics method to expose cache statistics (hits, misses, evictions, item count).
Updated Set, Get, and cleanupExpiredItems to track these metrics.
Added unit tests for new functionality.
…871551962453094290

Add batch operations and metrics monitoring
Refactored `MemoryStore` to use a sharded map approach (Concurrent Map pattern) with 256 shards. This reduces lock contention significantly compared to the previous single global lock design.

Changes:
- Replaced `mu` and `store` with `shards` slice in `MemoryStore`.
- Implemented `shard` struct with individual mutex and map.
- Added `getShard` method using FNV-1a hashing.
- Updated `Set`, `Get`, `Delete` to operate on specific shards.
- Optimized `SetMulti` and `GetMulti` to group keys by shard.
- Updated `cleanupExpiredItems` to iterate and lock shards individually, preventing "stop-the-world" pauses.
- Preserved lifecycle management using a dedicated `lifecycleMu`.
- Updated `GetMetrics` to aggregate stats from all shards.
…13428490407117788011

Refactor MemoryStore to use sharded storage
- Kept agnostic PubSub interface (In-Memory & GCP support)
- Preserved batch operations and metrics features
- Maintained comprehensive documentation
- Merged improved documentation structure from root
Copilot AI changed the title [WIP] Fix merge conflicts in metrics and batch operations Resolve merge conflicts between feature and root branches Dec 31, 2025
Copilot AI requested a review from BryceWayne December 31, 2025 23:52
@BryceWayne BryceWayne marked this pull request as ready for review December 31, 2025 23:53
@BryceWayne BryceWayne merged commit 7464de5 into feature/metrics-and-batch-ops-8871551962453094290 Dec 31, 2025
@BryceWayne BryceWayne deleted the copilot/sub-pr-12 branch December 31, 2025 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants