mirror of
https://github.com/renorris/openfsd
synced 2026-03-22 23:05:36 +08:00
Changes:
- Implement bootstrapping library for managing several concurrent internal services
- Refactor concurrency model for connections/logical clients and their associated I/O
- Refactor server context singleton
- Refactor error handling
- Most errors are now gracefully sent to the FSD client directly encoded as an $ER packet,
enhancing visibility and debugging
- Most errors are now rightfully treated as non-fatal
- Refactor package/dependency graph
- Refactor calling conventions/interfaces for many packages
- Refactor database package
- Refactor post office
Features:
- Add VATSIM-esque HTTP/JSON "data feed"
- Add ephemeral in-memory database option
- Add user management REST API
- Add improved web interface
- Add MySQL support (drop SQLite support)
30 lines
662 B
Go
30 lines
662 B
Go
package postoffice
|
|
|
|
// World holds a bucket for every 15-bit precision geohash,
|
|
// i.e. splitting the world into 2^15 buckets.
|
|
type World struct {
|
|
buckets [32768]GeohashBucket
|
|
}
|
|
|
|
func NewWorld() *World {
|
|
buckets := [32768]GeohashBucket{}
|
|
|
|
// Initialize all buckets
|
|
for i := 0; i < len(buckets); i++ {
|
|
buckets[i] = GeohashBucket{
|
|
addresses: make([]Address, 0),
|
|
}
|
|
}
|
|
|
|
return &World{buckets: buckets}
|
|
}
|
|
|
|
// Bucket returns the geohash bucket for `index` (15-bit geohash)
|
|
func (w *World) Bucket(index uint64) *GeohashBucket {
|
|
if index < 0 || index >= uint64(len(w.buckets)) {
|
|
panic("geohash bucket index out of bounds")
|
|
}
|
|
|
|
return &w.buckets[index]
|
|
}
|