Skip to content

Commit

Permalink
#17 add support for persistence (#18)
Browse files Browse the repository at this point in the history
* Added serde support for SpatialIndex

* Added support for snapshots and persistence

* Updated lockfile

* clippy

* Updated CHANGELOG

* Fixed issue with unwrapping snapshot.every

* Updated default config example
  • Loading branch information
ezrasingh authored Aug 23, 2024
1 parent e67e217 commit 37ce551
Show file tree
Hide file tree
Showing 23 changed files with 388 additions and 152 deletions.
30 changes: 30 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contrib/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Check the respective registry for available tags.

> For complete settings and configuration details, refer to the [Geoprox CLI README](../../geoprox/README.md#configuration).
To use a custom configuration file, simply mount your configuration file into the container at `/etc/geoprox`. Geoprox will automatically detect and parse configuration files in formats like `YAML`, `TOML`, `JSON`, or `INI` if they are named `geoprox.yaml`, `geoprox.toml`, `geoprox.json`, or `geoprox.ini`, respectively.
To use a custom configuration file, simply mount your configuration file into the container at `/var/lib/geoprox`. Geoprox will automatically detect and parse configuration files in formats like `YAML`, `TOML`, `JSON`, or `INI` if they are named `geoprox.yaml`, `geoprox.toml`, `geoprox.json`, or `geoprox.ini`, respectively.

For example, if you have a configuration file named `geoprox.yaml` in your current directory, you can run the container with the following command:

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
openapi.json
/snapshots
17 changes: 10 additions & 7 deletions contrib/docker/quickstart/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ services:
geoprox:
# I recommend pinning the tag to a specific version.
# Available tags can be found at https://hub.docker.com/repository/docker/ezrasingh/geoprox/tags
image: ezrasingh/geoprox:latest
image: ezrasingh/geoprox:${IMAGE_TAG:-latest}
restart: on-failure:3

# This is optional, demonstrating how to specify your config path.
# The default path is /etc/geoprox/
# This is optional, demonstrating how to specify env vars
# These are all the defaults
environment:
GEOPROX_CONFIG: /etc/geoprox/geoprox.toml
GEOPROX_CONFIG: /var/lib/geoprox/geoprox.toml
GEOPROX_HTTP_ADDR: 0.0.0.0
GEOPROX_HTTP_PORT: 5000

ports:
- 5000:5000
- ${HOST_PORT:-5000}:5000
volumes:
- ./geoprox.toml:/etc/geoprox/geoprox.toml:ro
- ./geoprox.toml:/var/lib/geoprox/geoprox.toml:ro
- ./snapshots/snapshot.bin:/var/lib/geoprox/snapshot.bin:z

# Here is an example to generate just the OpenAPI spec
geoprox-spec:
image: ezrasingh/geoprox:latest
image: ezrasingh/geoprox:${IMAGE_TAG:-latest}
entrypoint: ['geoprox', 'spec' ]
command: --destination /tmp --filename openapi.json --pretty
volumes:
Expand Down
16 changes: 14 additions & 2 deletions contrib/docker/quickstart/geoprox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@
http_addr = '0.0.0.0'
# The port the server will listen on
http_port = 5000
# Timeout duration in seconds
timeout = 10
# Request timeout
timeout = '10s'

[shard]
# Determines the default geohash length for inserts
insert_depth = 6
# Determines the default geohash length for searches
search_depth = 6
# Specifies the default number of results returned in range queries
default_count = 100
# Toggles the default sorting behavior for query results
default_sorted = false

[server.snapshots]
# Toggle snapshot usage
disabled = false
# Directory where snapshots will be stored
path = '/var/lib/geoprox'
# How often snapshots will be taken
every = '30s'
3 changes: 3 additions & 0 deletions geoprox-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Added support for key expirations ([#15](https://github.com/ezrasingh/geoprox/issues/15)).
- Implemented serde for `SpatialIndex` ([#17](https://github.com/ezrasingh/geoprox/issues/17)).

## 0.4.2

- Replaced the [`haversine`](https://crates.io/crates/haversine) crate with [`haversine-rs`](https://crates.io/crates/haversine-rs) after noticing it performed better in benchmarks.
Expand Down
1 change: 1 addition & 0 deletions geoprox-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ utoipa = { version = "4.2.3", optional = true }
[dev-dependencies]
criterion = "0.5.1"
rand = "0.8.5"
serde_test = "1.0.177"

[features]
utoipa = ["dep:utoipa"]
Expand Down
Loading

0 comments on commit 37ce551

Please sign in to comment.