Skip to content

Add NATS producer#442

Open
Bre77 wants to merge 25 commits intoteslamotors:mainfrom
Teslemetry:feature/nats-producer-improvements
Open

Add NATS producer#442
Bre77 wants to merge 25 commits intoteslamotors:mainfrom
Teslemetry:feature/nats-producer-improvements

Conversation

@Bre77
Copy link

@Bre77 Bre77 commented Jan 7, 2026

Description

Adds NATS as a producer. This has been in use in production by Teslemetry for over a year now.

Fixes # (issue)

Type of change

Please select all options that apply to this change:

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update

Checklist:

Confirm you have completed the following steps:

  • My code follows the style of this project.
  • I have performed a self-review of my code.
  • I have made corresponding updates to the documentation.
  • I have added/updated unit tests to cover my changes.
  • I have added/updated integration tests to cover my changes.

Bre77 and others added 25 commits January 7, 2026 20:53
Add a NATS publisher implementation and corresponding tests.

* **config/config.go**
  - Add NATS configuration struct to the Config struct.
  - Add NATS configuration to the ConfigureProducers method.
* **datastore/nats/nats.go**
  - Implement Producer struct for NATS.
  - Implement NewProducer function to initialize NATS producer.
  - Implement Produce method to send messages to NATS.
  - Implement Close method to close NATS connection.
  - Implement ProcessReliableAck method to handle reliable acknowledgements.
  - Implement ReportError method to report errors.
* **datastore/nats/nats_test.go**
  - Implement unit tests for NewProducer function.
  - Implement unit tests for Produce method.
  - Implement unit tests for Close method.
  - Implement unit tests for ProcessReliableAck method.
  - Implement unit tests for ReportError method.
* **.devcontainer/devcontainer.json**
  - Add devcontainer configuration for building the project.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/Teslemetry/tesla-fleet-telemetry?shareId=XXXX-XXXX-XXXX-XXXX).
* Add `nats.go` dependency to `go.mod`
* Add `nats.go`, `nkeys`, `nuid`, `compress`, `crypto`, `sync`, and `text` dependencies to `go.sum`
* Add import for `github.com/teslamotors/fleet-telemetry/metrics/adapter`
* Add tests for error handling, metrics, and different payload types in `TestProduce`
* Fix references to `metricsRegistry` fields to use exported fields
* Remove unused import for `context`

Update `.devcontainer/devcontainer.json`

* Add "test" task with command "make test"
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.

1 participant