Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Implementation status (2026-11-08):
* [x] Core server skeleton and TCP socket server
* [x] Sentry observability
* [x] Internal event bus for client notifications
* [ ] PostgreSQL data repository (replacing MongoDB, see [migration plan](doc/database-migration.md))
* [ ] PostgreSQL data repository (in progress; runs on in-memory storage until then, see [migration plan](doc/database-migration.md))
* [ ] Profile 0 - Basic Communication (partial)
* [ ] Profile 1 - Basic Object Based Workflow
* [ ] Profile 2 - Basic Running Order / Content List Workflow (partial)
Expand All @@ -28,7 +28,7 @@ The [roadmap](doc/roadmap.md) shows how ready each profile is, the milestones th

OpenMOS implements the MOS protocol using:
- **TCP Socket Server**: Maintains persistent connections with MOS clients (NCS systems)
- **PostgreSQL**: Stores running orders, stories, items, and MOS objects (migration from MongoDB in progress, see [database-migration.md](doc/database-migration.md))
- **PostgreSQL**: Stores running orders, stories, items, and MOS objects (in progress; until it lands the server keeps data in memory only, see [database-migration.md](doc/database-migration.md))
- **Sentry**: Provides error tracking and performance monitoring

The server handles multiple concurrent client connections, processes MOS XML messages, and manages the lifecycle of running orders and their associated content.
Expand Down Expand Up @@ -63,10 +63,6 @@ server:
readtimeout: 5s
writetimeout: 5s
shutdowntimeout: 30s
mongo: # to be replaced by a postgres block
uri: "mongodb+srv://localhost"
database: openmosdb01
timeout: 10s
mos:
id: mos01.station.com
heartbeatinterval: 30s
Expand Down Expand Up @@ -109,8 +105,8 @@ go build -o openmos

## Requirements

- Go 1.24.1 or later
- MongoDB 4.4 or later (current release; PostgreSQL 17 after the migration)
- Go 1.25 or later
- PostgreSQL 17 (once the PostgreSQL store lands; until then no database is needed)
- Network access on port 10540 (default MOS port)

## License
Expand Down
30 changes: 16 additions & 14 deletions doc/database-migration.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Database migration: MongoDB to PostgreSQL

OpenMOS is replacing MongoDB with PostgreSQL. MongoDB support will be removed,
not kept alongside, once the PostgreSQL store passes the same tests.
OpenMOS stores its data in PostgreSQL only. The original MongoDB store was
removed outright (MOS-34) rather than kept alongside or behind a switch.
Until the PostgreSQL store lands, the server runs on the in-memory reference
store (`internal/repository/memory`), so data is not persisted.

## Why

Expand All @@ -10,8 +12,8 @@ not kept alongside, once the PostgreSQL store passes the same tests.
- MOS messages such as `roCreate`, `roReplace` and `roStoryMove` change many
rows at once and must succeed or fail as a whole, which calls for
transactions.
- Only the storage layer (about 480 lines) uses MongoDB today, so switching
now is cheaper than after more profiles are built.
- Only the storage layer (about 480 lines) used MongoDB, so switching early
was cheaper than after more profiles were built.

## Tooling

Expand Down Expand Up @@ -40,25 +42,25 @@ Tables: `running_orders`, `stories`, `items`, `mos_objects`.

## Code changes

- `internal/db`: drop the MongoDB client; a new `internal/store/postgres`
- `internal/db` and the MongoDB repositories are gone; a new `internal/store/postgres`
package provides the pool, transactions and the four repositories.
- `internal/repository`: interfaces stay, with composite keys, ordering
operations and shared errors (`ErrNotFound`, `ErrVersionConflict`).
- `internal/repository`: interfaces stay, gaining composite keys and ordering
operations. Shared errors live in `errors.go` and grow with each change.
- Services run each MOS message in one transaction, and running order updates
use version-checked writes (optimistic locking).
- Configuration: the `mongo` block becomes a `postgres` block, with
`OPENMOS_DATABASE_URL` or the standard `PG*` environment variables.
- Configuration: the old `mongo` block is gone; a new `postgres` block, with
`DATABASE_URL` or the standard `PG*` environment variables.
- Startup can apply migrations automatically (`--migrate`) or only migrate and
exit (`--migrate-only`) for deployment jobs.

## Steps

1. Fix the build, add CI and an implementation-independent repository test
suite.
2. Add the schema migration and the PostgreSQL repositories, passing that
suite.
3. Switch the server to PostgreSQL and add transactions.
4. Remove the MongoDB code and driver, and update the documentation.
suite (MOS-11), with an in-memory reference store.
2. Remove the MongoDB code, driver and configuration (MOS-34).
3. Add the schema migration and the PostgreSQL repositories, passing that
suite (MOS-12 to MOS-14).
4. Add transactions and switch the server to PostgreSQL (MOS-15, MOS-16).

<hr />

Expand Down
29 changes: 8 additions & 21 deletions doc/developer-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ OpenMOS is an implementation of the Media Object Server (MOS) Protocol 4.0 using

| Component | Technology | Version |
|-----------|------------|---------|
| Language | Go | 1.24.1+ |
| Database | MongoDB | 4.4+ |
| Observability | Sentry | v0.31.1 |
| Language | Go | 1.25+ |
| Database | PostgreSQL (in progress; in-memory until then) | 17 |
| Observability | Sentry | v0.50 |
| Communication | TCP Sockets | Port 10540 |
| Configuration | YAML | gopkg.in/yaml.v3 |
| Configuration | YAML | go.yaml.in/yaml/v3 |

## Architecture

Expand Down Expand Up @@ -42,7 +42,7 @@ OpenMOS follows a **Clean Layered Architecture** with clear separation of concer
│
┌─────────────────────────▼───────────────────────────────────┐
│ Database Layer │
│ (MongoDB) │
│ (PostgreSQL; in-memory store until MOS-16) │
└─────────────────────────────────────────────────────────────┘
```

Expand All @@ -56,7 +56,6 @@ OpenMOS follows a **Clean Layered Architecture** with clear separation of concer
| **Repository** | `internal/repository/` | Data access abstraction, CRUD operations |
| **Model** | `internal/model/` | Domain entities and value objects |
| **XML** | `internal/xml/` | Message parsing and serialization |
| **Database** | `internal/db/` | MongoDB connection and collection management |
| **Events** | `internal/events/` | Pub-sub event bus for real-time notifications |
| **Utilities** | `pkg/` | Logging, monitoring, shared helpers |

Expand All @@ -73,10 +72,6 @@ OpenMOS/
│ │ ├── config/
│ │ │ └── config.go # YAML/env configuration loader
│ │ │
│ │ ├── db/
│ │ │ ├── db.go # Database interface
│ │ │ └── mongo.go # MongoDB implementation
│ │ │
│ │ ├── events/
│ │ │ └── bus.go # EventBus pub-sub implementation
│ │ │
Expand All @@ -87,10 +82,6 @@ OpenMOS/
│ │ ├── repository/
│ │ │ ├── repository.go # Interface definitions
│ │ │ ├── errors.go # Shared errors (ErrNotFound, ...)
│ │ │ ├── runningorder.go # RunningOrder MongoDB repo
│ │ │ ├── story.go # Story MongoDB repo
│ │ │ ├── item.go # Item MongoDB repo
│ │ │ ├── object.go # MOSObject MongoDB repo
│ │ │ ├── memory/ # In-memory reference implementation
│ │ │ └── repotest/ # Contract suite for every implementation
│ │ │
Expand Down Expand Up @@ -165,15 +156,16 @@ RunningOrder (1) ──► (N) Story ──► (N) Item ──► MOSObject
2. **Heartbeat Monitoring**: Client heartbeat is tracked; timeout triggers disconnection
3. **Message Reception**: XML messages are parsed and validated
4. **Service Processing**: Business logic handles operations (create/update/replace)
5. **Database Storage**: Changes are persisted to MongoDB
5. **Storage**: Changes are stored through the repository interfaces (in memory until the PostgreSQL store lands)
6. **Event Publishing**: Service publishes events to the event bus
7. **Client Notification**: Connected clients receive real-time updates via subscriptions

## Implemented Features

### Core Infrastructure
- [x] TCP Socket Server with multi-client support
- [x] MongoDB data persistence with repository pattern
- [x] Repository pattern with a contract test suite and an in-memory store
- [ ] PostgreSQL persistence (M1, see database-migration.md)
- [x] YAML configuration with environment variable overrides
- [x] Multi-level logging with Sentry integration
- [x] Client heartbeat monitoring with timeout detection
Expand Down Expand Up @@ -285,11 +277,6 @@ server:
writetimeout: 5s # Write timeout duration
shutdowntimeout: 30s # Graceful shutdown timeout

mongo:
uri: "mongodb://localhost" # MongoDB connection URI
database: openmosdb01 # Database name
timeout: 10s # Connection timeout

mos:
id: mos01.station.com # MOS server identifier
heartbeatinterval: 30s # Heartbeat interval
Expand Down
2 changes: 1 addition & 1 deletion doc/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This section contains the documentation of the OpenMOS project.

- [Roadmap](./roadmap.md) - Readiness by MOS profile, milestones and known issues

- [Database migration](./database-migration.md) - Plan for moving from MongoDB to PostgreSQL
- [Database migration](./database-migration.md) - Plan for moving storage to PostgreSQL

- [Development tasks](./devtasks.md)

Expand Down
2 changes: 1 addition & 1 deletion doc/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Status as of 2026-11-08 (commit `3a73754`).
Milestones run in order; each one builds on the previous.

1. **M1 Foundations and PostgreSQL.** Build passes for the whole module, CI runs
build, vet and tests, and storage moves from MongoDB to PostgreSQL.
build, vet and tests, and storage moves to PostgreSQL.
See [database-migration.md](./database-migration.md).
2. **M2 Wire protocol and Profile 0.** Messages use the `<mos>` envelope
(`mosID`, `ncsID`, `messageID`), UTF-16BE encoding, robust stream framing,
Expand Down
10 changes: 0 additions & 10 deletions src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,10 @@ go 1.25.0

require (
github.com/getsentry/sentry-go v0.50.0
go.mongodb.org/mongo-driver v1.17.3
go.yaml.in/yaml/v3 v3.0.6
)

require (
github.com/golang/snappy v0.0.4 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
golang.org/x/crypto v0.36.0 // indirect
golang.org/x/sync v0.22.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/text v0.41.0 // indirect
)
44 changes: 0 additions & 44 deletions src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ github.com/getsentry/sentry-go v0.50.0 h1:gkO59rn/i0RCAXUUTflC5QVbTQGPXbaFabs2ol
github.com/getsentry/sentry-go v0.50.0/go.mod h1:+xsDuN+SoRN/xfs1hdq78wnrE3omIZf+FCuh9FOW1C8=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand All @@ -20,51 +14,13 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/mongo-driver v1.17.3 h1:TQyXhnsWfWtgAhMtOgtYHMTkZIfBTpMTsMnd9ZBeHxQ=
go.mongodb.org/mongo-driver v1.17.3/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.yaml.in/yaml/v3 v3.0.6 h1:zcDfvjXEqTQmpjniUBLc91xYJMB2c4QOFxEF/LCEckM=
go.yaml.in/yaml/v3 v3.0.6/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
7 changes: 0 additions & 7 deletions src/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ type Config struct {
ShutdownTimeout time.Duration
}

// MongoDB configuration
Mongo struct {
URI string
Database string
Timeout time.Duration
}

// MOS configuration
MOS struct {
// MOS ID of this server, used in MOS messages
Expand Down
5 changes: 0 additions & 5 deletions src/internal/config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ func GenerateDefaultConfig(filePath string) error {
config.Server.WriteTimeout = 5 * time.Second
config.Server.ShutdownTimeout = 30 * time.Second

// MongoDB config
config.Mongo.URI = "mongodb://localhost:27017"
config.Mongo.Database = "openmos"
config.Mongo.Timeout = 10 * time.Second

// MOS config
config.MOS.ID = "OpenMOS_Server"
config.MOS.HeartbeatInterval = 30 * time.Second
Expand Down
11 changes: 0 additions & 11 deletions src/internal/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ func applyEnvOverrides(config *Config, yamlLoaded bool) {
config.Server.ShutdownTimeout = getEnvAsDuration("SERVER_SHUTDOWN_TIMEOUT", getDefaultDuration(config.Server.ShutdownTimeout, 30*time.Second))
}

// MongoDB config
if envVal := getEnv("MONGODB_URI", ""); envVal != "" || !yamlLoaded {
config.Mongo.URI = getEnv("MONGODB_URI", getDefaultString(config.Mongo.URI, "mongodb://localhost:27017"))
}
if envVal := getEnv("MONGODB_DATABASE", ""); envVal != "" || !yamlLoaded {
config.Mongo.Database = getEnv("MONGODB_DATABASE", getDefaultString(config.Mongo.Database, "openmos"))
}
if envVal := getEnv("MONGODB_TIMEOUT", ""); envVal != "" || !yamlLoaded {
config.Mongo.Timeout = getEnvAsDuration("MONGODB_TIMEOUT", getDefaultDuration(config.Mongo.Timeout, 10*time.Second))
}

// MOS config
if envVal := getEnv("MOS_ID", ""); envVal != "" || !yamlLoaded {
config.MOS.ID = getEnv("MOS_ID", getDefaultString(config.MOS.ID, "OpenMOS_Server"))
Expand Down
3 changes: 0 additions & 3 deletions src/internal/config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ var configEnvKeys = []string{
"CONFIG_FILE",
"APP_NAME", "APP_VERSION", "APP_ENV",
"SERVER_HOST", "SERVER_PORT", "SERVER_READ_TIMEOUT", "SERVER_WRITE_TIMEOUT", "SERVER_SHUTDOWN_TIMEOUT",
"MONGODB_URI", "MONGODB_DATABASE", "MONGODB_TIMEOUT",
"MOS_ID", "MOS_HEARTBEAT_INTERVAL", "MOS_CLIENT_TIMEOUT",
"LOG_LEVEL",
"SENTRY_DSN", "SENTRY_ENV", "SENTRY_DEBUG", "SENTRY_ATTACH_STACKTRACE",
Expand Down Expand Up @@ -48,8 +47,6 @@ func TestLoadConfigDefaultsWithoutYAML(t *testing.T) {
want.Server.Host, want.Server.Port = "0.0.0.0", 10540
want.Server.ReadTimeout, want.Server.WriteTimeout = 5*time.Second, 5*time.Second
want.Server.ShutdownTimeout = 30 * time.Second
want.Mongo.URI, want.Mongo.Database = "mongodb://localhost:27017", "openmos"
want.Mongo.Timeout = 10 * time.Second
want.MOS.ID = "OpenMOS_Server"
want.MOS.HeartbeatInterval, want.MOS.ClientTimeout = 30*time.Second, 2*time.Minute
want.Logging.Level = "info"
Expand Down
Loading
Loading