Skip to content

efumagal/sevenseas

Repository files navigation

Seven Seas

golangci-lint test

Run

docker compose up --build -d
docker compose down

When completed access the Redis UI:

Redis Web UI

Screenshot 2023-06-29 at 22 57 08

(Accept Terms the first time, could probably be avoided with some config passed to the Docker container)

Screenshot 2023-06-29 at 20 17 41

Develop

For development it is possible to run the docker compose that is just starting Redis

docker compose -f docker-compose-development.yml up --build -d

To run:

go run main.go

2023/06/30 09:56:27 Starting
2023/06/30 09:56:27 Redis host localhost:6379
2023/06/30 09:56:27 Port file ../data/ports.json
2023/06/30 09:56:27 Added 1632 Took 799.934125ms
docker compose down

Tests

go test ./...

At the moment there are only few tests for demonstration.
Coverage can be checked with:

go test ./... -cover

In a real repo there may be a check on minimum coverage.

Unit tests:

Functional test (sort of):

Apart from the tests in the repo there will be end to end tests involving real external resources (DBs, third party services...).

TO DOs

  • Add constructor with validation for PortData
  • PortData.Coordinates could be a specific struct with lat, lon and validation
  • Mock Redis and Postgres to be able to create tests
  • Add more tests and maybe a check on the coverage
  • Now the service that is injesting to the DB exits immediately, with more time an API (gRPC, REST) could have been added
  • Better naming and spend more time on the code structure to fit with Hexagonal patterns

Notes

  • Generated a file with 100k random ports, that took ~30s to add to the DB.
    In case of large files (although I think the data would probably be on another DB) it might be worth investigating if it is possible to split the file and upload to the DB in parallel.
  • Redis was chosen for simplicity but depending on the access patterns (maybe a query by Country) another DB might be more appropriate.
  • When tested with Redis the SavePort function was also updating if item already present

Links

About

Ports management

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published