https://github.com/sultaniman/hive-state
In-memory fleet state management
https://github.com/sultaniman/hive-state
fleet fleet-management fleet-state fleet-tracking fleetops
Last synced: 6 months ago
JSON representation
In-memory fleet state management
- Host: GitHub
- URL: https://github.com/sultaniman/hive-state
- Owner: sultaniman
- License: apache-2.0
- Created: 2020-04-26T13:52:50.000Z (about 6 years ago)
- Default Branch: develop
- Last Pushed: 2020-05-10T19:17:45.000Z (about 6 years ago)
- Last Synced: 2025-10-07T00:50:27.532Z (8 months ago)
- Topics: fleet, fleet-management, fleet-state, fleet-tracking, fleetops
- Language: Elixir
- Homepage:
- Size: 183 KB
- Stars: 7
- Watchers: 0
- Forks: 1
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README


[](https://houndci.com)
[](https://opensource.org/licenses/Apache-2.0)
Hive
Efficient in-memory fleet state management.
## Installation 💾
This library can be installed by adding `hive` to the list of dependencies in
your `mix.exs`:
```elixir
def deps do
[{:hive, "~> 0.0.1"}]
end
```
Add `:hive` to `extra_applications` if necessary.
## Usage 🚀
Once you have it running you can infleet, defleet, update positions, get h3 index for vehicles
```elixir
alias Hive.Vehicle
# Infleet new vehicles
{:ok, _pid} = Hive.infleet("autonomous-vehicle-id")
{:ok, _pid} = Hive.infleet(%Vehicle{id: "autonomous-vehicle-id"})
{:ok, _pid} = Hive.infleet("normal-vehicle-id")
{:ok, _pid} = Hive.infleet(%Vehicle{id: "normal-vehicle-id"})
# Defleet vehicles
{:ok, _pid} = Hive.defleet("normal-vehicle-id")
{:ok, _pid} = Hive.defleet(%Vehicle{id: "normal-vehicle-id"})
```
If we in-fleet only by `vehicle_id` then `%Vehicle{}` struct
is created with default field values. We also can in-fleet giving
full `%Vehicle{}` with all parameters you want.
### Structs
Hive has two structs `Vehicle` and `GeoPosition`
```elixir
%GeoPosition{
latitude: float(),
longitude: float(),
accuracy: float(),
altitude: float(),
altitude_accuracy: float(),
heading: float(),
speed: float()
}
%Vehicle{
id: String.t(),
vin: String.t() | nil,
name: String.t() | nil,
license_plate: String.t() | nil,
make: String.t() | nil,
model: String.t() | nil,
seat_count: non_neg_integer() | nil,
color: String.t() | nil,
online: boolean() | true,
has_passengers: boolean() | false,
is_sdc: boolean() | false,
position: GeoPosition.t() | nil,
telemetry: list() | []
}
```
Supervision tree looks like

For more usage details please refer to https://hex.pm/packages/hive
### H3 queries 🍪
H3 integration is done via https://github.com/helium/erlang-h3 and at the moment the following
features are supported
```elixir
# Get hexagon index for vehicle or GeoPosition
Hive.H3.index("vehicle-uuid")
Hive.H3.index(%GeoPosition{latitude: 48.8566, longitude: 2.3522})
# H3 index to GeoPosition
H3.index_to_geo("8928308280fffff")
H3.index_to_geo(617_700_169_958_293_503)
# Get geo boundary
H3.to_geo_boundary("8928308280fffff")
H3.to_geo_boundary(613_196_840_967_340_031)
# Get kRing
H3.k_ring("8928308280fffff", 1)
H3.k_ring(613_196_840_967_340_031, 1)
```
For more see `Hive.H3` module documentation.
## The future 🌈
More features and integrations with H3 will be available in the future
at the moment the main goal is to stabilize the API and release
the first version with clear documentation how setup and use `Hive`.
## Assets 💄
1. Project logo is from https://www.flaticon.com/free-icon/honeycomb_1598428
Enjoy!
✨ 🍰 ✨