mattermost/server/platform/services/remotecluster
Jesse Hallam e3fbf8711f
MM-68149: Upgrade to Go 1.26.2 (#36418)
* MM-68149: upgrade to Go 1.26.2

Update go directive in go.mod and .go-version.

* MM-68149: replace pointer helpers with Go 1.26 new()

Go 1.26 extends the built-in new() to accept an initial value expression,
making typed-pointer helpers like model.NewPointer(x), bToP(x), and boolPtr(x)
redundant. Replace every call site with new(x) and remove the now-unused
helper functions and their //go:fix inline directives.

* MM-68149: apply go fix for reflect API and format-string changes

- reflect.Ptr → reflect.Pointer (renamed in Go 1.18, deprecated alias removed in 1.26)
- reflect range-over-struct: for i := 0; i < t.NumField(); i++ → for field := range t.Fields()
  and the equivalent for Methods() and interface types
- Fix format-string concatenation and variadic-arg mismatches flagged by go vet

* MM-68149: update JPEG fixtures and test infrastructure for Go 1.26 encoder

Go 1.26 ships a new image/jpeg encoder that produces slightly different output.
Regenerate all JPEG fixture files and switch the comparison helpers from
byte-equality to pixel-level comparison with a small per-channel tolerance,
so minor encoder drift across patch versions is handled automatically.

Add -update-fixtures flag to make it easy to regenerate fixtures after future
major Go upgrades. Document the update procedure in tests/README.md.

* MM-68149: CI check that go fix ./... produces no changes

* Fix real bugs flagged by CodeRabbit review

- group.go: set newGroup.MemberCount not group.MemberCount (member count
  was populated on the wrong variable and lost before publish/return)
- file_test.go: guard compareImage(GetFilePreview) on the preview slice
  length, not the thumbnail slice length (copy-paste error)
- config_test.go: remove duplicate MinimumLength assignment

* fixup! Fix real bugs flagged by CodeRabbit review
2026-05-12 15:59:12 +00:00
..
error.go Return an error if an invite for a confirmed remote cluster is received (#28943) 2024-10-25 11:30:29 +02:00
invitation.go MM-64522: Use PBKDF2 as the new key derivation for remote cluster invitation (#33493) 2025-07-21 19:08:31 +05:30
mocks_test.go Fix MM-65152 (#34199) 2025-10-29 07:52:34 -07:00
ping.go MM-68204: Use multi-level logging for shared channel and remote cluster service errors (#35949) 2026-04-06 12:17:47 -04:00
ping_test.go MM-68179: Run sendLoop workers on all HA nodes (#35909) 2026-04-07 18:49:54 +02:00
README.md add readme to the remotecluster and sharedchannel service directories (#30123) 2025-02-26 19:35:54 +01:00
recv.go MM-68204: Use multi-level logging for shared channel and remote cluster service errors (#35949) 2026-04-06 12:17:47 -04:00
recv_test.go Validate RefreshedToken differs from original invite token (#34864) 2026-03-13 19:07:40 +00:00
response.go Mono repo -> Master (#22553) 2023-03-22 17:22:27 -04:00
send.go Mono repo -> Master (#22553) 2023-03-22 17:22:27 -04:00
send_test.go MM-68179: Run sendLoop workers on all HA nodes (#35909) 2026-04-07 18:49:54 +02:00
sendfile.go MM-68204: Use multi-level logging for shared channel and remote cluster service errors (#35949) 2026-04-06 12:17:47 -04:00
sendmsg.go MM-68204: Use multi-level logging for shared channel and remote cluster service errors (#35949) 2026-04-06 12:17:47 -04:00
sendprofileImage.go MM-68204: Use multi-level logging for shared channel and remote cluster service errors (#35949) 2026-04-06 12:17:47 -04:00
sendprofileImage_test.go MM-68149: Upgrade to Go 1.26.2 (#36418) 2026-05-12 15:59:12 +00:00
service.go MM-68179: Run sendLoop workers on all HA nodes (#35909) 2026-04-07 18:49:54 +02:00
service_test.go MM-68179: Run sendLoop workers on all HA nodes (#35909) 2026-04-07 18:49:54 +02:00

Remote Cluster Service

Package remotecluster implements Mattermost's "Secured Connections" feature, which enables communication between different Mattermost clusters. Specifically, this package provides:

Service Management:

  • Manages inter-cluster communication via topic-based messages
  • Handles connection state (active/inactive) based on cluster leadership
  • Maintains concurrent send channels (MaxConcurrentSends = 10) for parallel message processing
  • Implements periodic health checks (pings) to monitor remote cluster connectivity

Message Handling:

  • Sends messages using a pool of goroutines to handle concurrent sends while preserving message order per remote
  • Uses hash-based routing to ensure messages for the same remote ID go to the same channel
  • Supports different types of sends: messages, files, and profile images
  • Implements topic-based message routing with listener callbacks

Connection Management:

  • Handles invitation confirmations between clusters
  • Maintains HTTP client connections with proper timeouts and transport settings
  • Supports connection state listeners for monitoring remote cluster availability
  • Implements ping mechanism to verify remote cluster health

Core Features:

  • Topic-based message routing
  • File transfer capabilities
  • Profile image synchronization
  • Invitation system for establishing connections
  • Health monitoring via pings
  • Concurrent message processing
  • Connection state management

This package is designed to be thread-safe and handles leadership changes in clustered environments, only running active operations on the leader node.