maxmind-db-rust 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +52 -0
- data/CONTRIBUTING.md +496 -0
- data/LICENSE +15 -0
- data/README.md +343 -0
- data/ext/maxmind_db_rust/Cargo.toml +25 -0
- data/ext/maxmind_db_rust/extconf.rb +5 -0
- data/ext/maxmind_db_rust/lib/maxmind/db/rust.rb +16 -0
- data/ext/maxmind_db_rust/src/lib.rs +970 -0
- data/lib/maxmind/db/rust.rb +135 -0
- metadata +183 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a8a276001be2894f2077b32bc833051a40922891d60583fda41da26ce7c9b110
|
|
4
|
+
data.tar.gz: 625a38e437c4d38c201776b46d4792801293c9c04ac3555c2e0789f7822ffedd
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: df07261c650c082ce6dec86de6962400dbcc2572f0fa23afb97b54f0360536f4c4f91833cc106343060ac1be706f4e7b9cc3ffe1d9bd403b50f2986df28893b6
|
|
7
|
+
data.tar.gz: 8b57f7028871d833246105c197d15aaf26f5d644f6133d139b9bf638b8ac1c228e83d4ef019f857525ad49f0e4f83889a0003b2f47c4b687098dafc1b98c966e
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.2] - 2025-11-15
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Automated release script (`dev-bin/release.sh`) that validates changelog dates, updates gemspec version, runs tests, and creates GitHub releases
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Updated actions/checkout from v4 to v5 in GitHub workflows
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Release workflow no longer runs twice (removed redundant triggers)
|
|
21
|
+
|
|
22
|
+
### Removed
|
|
23
|
+
|
|
24
|
+
- Unused test/maxmind-db-reader-ruby git submodule (documentation now references upstream repository by URL)
|
|
25
|
+
|
|
26
|
+
## [0.1.1] - 2025-11-15
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- Release workflow now has environment set.
|
|
31
|
+
|
|
32
|
+
## [0.1.0] - 2025-11-15
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Initial release
|
|
37
|
+
- Reader class with `get()`, `get_with_prefix_length()`, `metadata()`, `close()`, and `closed()` methods
|
|
38
|
+
- Metadata class with all standard MaxMind DB metadata attributes
|
|
39
|
+
- Support for MODE_AUTO, MODE_MEMORY, and MODE_MMAP modes
|
|
40
|
+
- Iterator support via `each` method (Enumerable interface)
|
|
41
|
+
- Iterate over all networks in database
|
|
42
|
+
- Network-scoped iteration with optional CIDR parameter (String or IPAddr)
|
|
43
|
+
- InvalidDatabaseError exception for corrupt databases
|
|
44
|
+
- Thread-safe implementation using Rust Arc and RwLock
|
|
45
|
+
- Support for both String and IPAddr IP address inputs
|
|
46
|
+
- High-performance Rust implementation using maxminddb crate
|
|
47
|
+
- Comprehensive API documentation
|
|
48
|
+
|
|
49
|
+
### Not Implemented
|
|
50
|
+
|
|
51
|
+
- MODE_FILE support (use MODE_MMAP instead)
|
|
52
|
+
- File descriptor support in constructor
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
# Contributing to maxmind-db-rust
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to maxmind-db-rust! This document provides guidelines and instructions for developers.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Development Setup](#development-setup)
|
|
8
|
+
- [Building the Extension](#building-the-extension)
|
|
9
|
+
- [Running Tests](#running-tests)
|
|
10
|
+
- [Code Quality](#code-quality)
|
|
11
|
+
- [Project Structure](#project-structure)
|
|
12
|
+
- [Making Changes](#making-changes)
|
|
13
|
+
- [Testing Guidelines](#testing-guidelines)
|
|
14
|
+
- [Submitting Changes](#submitting-changes)
|
|
15
|
+
- [Release Process](#release-process)
|
|
16
|
+
|
|
17
|
+
## Development Setup
|
|
18
|
+
|
|
19
|
+
### Prerequisites
|
|
20
|
+
|
|
21
|
+
- Ruby 3.2 or higher
|
|
22
|
+
- Rust toolchain (stable)
|
|
23
|
+
- Bundler
|
|
24
|
+
- Git
|
|
25
|
+
|
|
26
|
+
### Installing Rust
|
|
27
|
+
|
|
28
|
+
If you don't have Rust installed:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
32
|
+
source $HOME/.cargo/env
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Clone and Setup
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
git clone https://github.com/oschwald/maxmind-db-rust-ruby.git
|
|
39
|
+
cd maxmind-db-rust-ruby
|
|
40
|
+
|
|
41
|
+
# Initialize git submodules (for test data)
|
|
42
|
+
git submodule update --init --recursive
|
|
43
|
+
|
|
44
|
+
# Install dependencies
|
|
45
|
+
bundle install
|
|
46
|
+
|
|
47
|
+
# Configure git to use the .githooks directory
|
|
48
|
+
git config core.hooksPath .githooks
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
This will enable the pre-commit hook that runs `precious lint` on staged files before each commit.
|
|
52
|
+
|
|
53
|
+
## Building the Extension
|
|
54
|
+
|
|
55
|
+
### First Time Build
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Compile the Rust extension
|
|
59
|
+
bundle exec rake compile
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This will:
|
|
63
|
+
|
|
64
|
+
1. Run `extconf.rb` to generate the Makefile
|
|
65
|
+
2. Compile the Rust code using rb-sys
|
|
66
|
+
3. Place the compiled extension in `lib/maxmind/db/`
|
|
67
|
+
|
|
68
|
+
### Clean Build
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Clean build artifacts
|
|
72
|
+
bundle exec rake clean
|
|
73
|
+
|
|
74
|
+
# Clean and rebuild
|
|
75
|
+
bundle exec rake clobber compile
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Development Build (Debug)
|
|
79
|
+
|
|
80
|
+
The default rake task builds in release mode. For faster compile times during development:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Set environment variable for debug builds
|
|
84
|
+
CARGO_PROFILE=dev bundle exec rake compile
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Note: Debug builds are significantly slower at runtime but compile faster.
|
|
88
|
+
|
|
89
|
+
## Running Tests
|
|
90
|
+
|
|
91
|
+
### Test Organization
|
|
92
|
+
|
|
93
|
+
Tests are organized into two categories:
|
|
94
|
+
|
|
95
|
+
1. **Our Own Tests** (`test/*_test.rb`)
|
|
96
|
+
- Tests specific to this implementation
|
|
97
|
+
- License: ISC (same as project)
|
|
98
|
+
|
|
99
|
+
2. **MaxMind Upstream Tests** (`test/maxmind/test_*.rb`)
|
|
100
|
+
- Adapted from official MaxMind-DB-Reader-ruby
|
|
101
|
+
- License: Apache-2.0 or MIT (MaxMind, Inc.)
|
|
102
|
+
- See `test/maxmind/README.md` for details
|
|
103
|
+
|
|
104
|
+
### Running Tests
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Run all tests (recommended before submitting PR)
|
|
108
|
+
bundle exec rake test
|
|
109
|
+
|
|
110
|
+
# Run only our own tests
|
|
111
|
+
bundle exec rake test_own
|
|
112
|
+
|
|
113
|
+
# Run only MaxMind upstream compatibility tests
|
|
114
|
+
bundle exec rake test_maxmind
|
|
115
|
+
|
|
116
|
+
# Run with verbose output
|
|
117
|
+
bundle exec rake test_verbose
|
|
118
|
+
|
|
119
|
+
# Run specific test file
|
|
120
|
+
bundle exec ruby test/reader_test.rb
|
|
121
|
+
|
|
122
|
+
# Run specific test method
|
|
123
|
+
bundle exec ruby test/reader_test.rb -n test_get_ipv4_address
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Test Data
|
|
127
|
+
|
|
128
|
+
Test databases are stored in `test/data/MaxMind-DB/` as a git submodule. If tests are failing with "file not found" errors:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
git submodule update --init --recursive
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Code Quality
|
|
135
|
+
|
|
136
|
+
### Precious (Recommended)
|
|
137
|
+
|
|
138
|
+
The easiest way to run all linters and formatters is using [precious](https://github.com/houseabsolute/precious):
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Install precious (once)
|
|
142
|
+
cargo install precious
|
|
143
|
+
|
|
144
|
+
# Check all linters
|
|
145
|
+
precious lint --all
|
|
146
|
+
|
|
147
|
+
# Auto-fix all issues
|
|
148
|
+
precious tidy --all
|
|
149
|
+
|
|
150
|
+
# Check only staged files (useful before committing)
|
|
151
|
+
precious lint --staged
|
|
152
|
+
|
|
153
|
+
# Run specific linter
|
|
154
|
+
precious lint -c rubocop
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The pre-commit hook automatically runs `precious lint --staged` before each commit.
|
|
158
|
+
|
|
159
|
+
### RuboCop (Ruby)
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Check Ruby code style
|
|
163
|
+
bundle exec rubocop
|
|
164
|
+
|
|
165
|
+
# Auto-fix issues
|
|
166
|
+
bundle exec rubocop -a
|
|
167
|
+
|
|
168
|
+
# Check specific files
|
|
169
|
+
bundle exec rubocop lib/maxmind/db/rust.rb
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Clippy (Rust)
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Run Rust linter
|
|
176
|
+
cd ext/maxmind_db_rust
|
|
177
|
+
cargo clippy -- -D warnings
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Formatting
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Format Rust code
|
|
184
|
+
cd ext/maxmind_db_rust
|
|
185
|
+
cargo fmt
|
|
186
|
+
|
|
187
|
+
# Check formatting without changing files
|
|
188
|
+
cargo fmt -- --check
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Project Structure
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
maxmind-db-rust-ruby/
|
|
195
|
+
├── ext/maxmind_db_rust/ # Rust extension code
|
|
196
|
+
│ ├── Cargo.toml # Rust dependencies
|
|
197
|
+
│ ├── extconf.rb # Ruby build configuration
|
|
198
|
+
│ └── src/
|
|
199
|
+
│ └── lib.rs # Main Rust implementation
|
|
200
|
+
├── lib/ # Ruby integration layer
|
|
201
|
+
│ └── maxmind/
|
|
202
|
+
│ └── db/
|
|
203
|
+
│ └── rust.rb # Ruby API wrapper
|
|
204
|
+
├── test/ # Test suite
|
|
205
|
+
│ ├── *_test.rb # Our own tests
|
|
206
|
+
│ ├── maxmind/ # Upstream tests (MaxMind copyright)
|
|
207
|
+
│ │ ├── README.md # Licensing info
|
|
208
|
+
│ │ └── test_*.rb # Adapted tests
|
|
209
|
+
│ └── data/
|
|
210
|
+
│ └── MaxMind-DB/ # Test databases (submodule)
|
|
211
|
+
├── Rakefile # Build and test tasks
|
|
212
|
+
├── maxmind-db-rust.gemspec # Gem specification
|
|
213
|
+
├── README.md # User documentation
|
|
214
|
+
├── CONTRIBUTING.md # This file
|
|
215
|
+
├── CHANGELOG.md # Version history
|
|
216
|
+
└── LICENSE # ISC License
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Making Changes
|
|
220
|
+
|
|
221
|
+
### Workflow
|
|
222
|
+
|
|
223
|
+
1. **Create a branch** for your changes:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
git checkout -b feature/my-new-feature
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
2. **Make your changes**:
|
|
230
|
+
- Rust code: `ext/maxmind_db_rust/src/lib.rs`
|
|
231
|
+
- Ruby wrapper: `lib/maxmind/db/rust.rb`
|
|
232
|
+
- Tests: Add tests in `test/` directory
|
|
233
|
+
|
|
234
|
+
3. **Compile and test**:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
bundle exec rake compile
|
|
238
|
+
bundle exec rake test
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
4. **Check code quality**:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
bundle exec rubocop
|
|
245
|
+
cd ext/maxmind_db_rust && cargo clippy && cargo fmt
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
5. **Commit your changes**:
|
|
249
|
+
```bash
|
|
250
|
+
git add .
|
|
251
|
+
git commit -m "Add feature: description"
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Commit Message Guidelines
|
|
255
|
+
|
|
256
|
+
- Use present tense ("Add feature" not "Added feature")
|
|
257
|
+
- Use imperative mood ("Move cursor to..." not "Moves cursor to...")
|
|
258
|
+
- First line should be 50 characters or less
|
|
259
|
+
- Reference issues and pull requests when relevant
|
|
260
|
+
|
|
261
|
+
Example:
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
Add support for custom metadata attributes
|
|
265
|
+
|
|
266
|
+
- Implement metadata attribute getter
|
|
267
|
+
- Add tests for custom attributes
|
|
268
|
+
- Update documentation
|
|
269
|
+
|
|
270
|
+
Fixes #123
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Testing Guidelines
|
|
274
|
+
|
|
275
|
+
### Writing Tests
|
|
276
|
+
|
|
277
|
+
When adding new features or fixing bugs:
|
|
278
|
+
|
|
279
|
+
1. **Add tests to our own test suite** (`test/*_test.rb`):
|
|
280
|
+
|
|
281
|
+
```ruby
|
|
282
|
+
def test_new_feature
|
|
283
|
+
reader = MaxMind::DB::Rust::Reader.new('path/to/test.mmdb')
|
|
284
|
+
result = reader.new_method
|
|
285
|
+
assert_equal expected_value, result
|
|
286
|
+
reader.close
|
|
287
|
+
end
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
2. **Ensure existing tests pass**:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
bundle exec rake test
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
3. **Test both modes** (MMAP and MEMORY) when relevant:
|
|
297
|
+
```ruby
|
|
298
|
+
[MaxMind::DB::Rust::MODE_MMAP, MaxMind::DB::Rust::MODE_MEMORY].each do |mode|
|
|
299
|
+
reader = MaxMind::DB::Rust::Reader.new(path, mode: mode)
|
|
300
|
+
# Test logic here
|
|
301
|
+
reader.close
|
|
302
|
+
end
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Test Coverage
|
|
306
|
+
|
|
307
|
+
- Test normal operation (happy path)
|
|
308
|
+
- Test edge cases (empty results, boundary conditions)
|
|
309
|
+
- Test error conditions (invalid input, closed readers, etc.)
|
|
310
|
+
- Test thread safety for concurrent operations
|
|
311
|
+
- Test both IPv4 and IPv6 addresses
|
|
312
|
+
|
|
313
|
+
### Upstream Test Synchronization
|
|
314
|
+
|
|
315
|
+
When the official MaxMind-DB-Reader-ruby gem is updated:
|
|
316
|
+
|
|
317
|
+
1. Clone or update a local copy of the upstream repository:
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
# Clone to a temporary location
|
|
321
|
+
git clone https://github.com/maxmind/MaxMind-DB-Reader-ruby.git /tmp/maxmind-db-reader-ruby
|
|
322
|
+
cd /tmp/maxmind-db-reader-ruby
|
|
323
|
+
|
|
324
|
+
# Or update existing clone
|
|
325
|
+
git pull origin main
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
2. Review changes:
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
cd /tmp/maxmind-db-reader-ruby
|
|
332
|
+
git log --oneline --since="3 months ago" -- test/
|
|
333
|
+
git diff HEAD~10..HEAD -- test/test_reader.rb
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
3. Apply relevant changes to `test/maxmind/test_reader.rb`:
|
|
337
|
+
- Maintain our namespace changes (MaxMind::DB::Rust)
|
|
338
|
+
- Keep MODE_MMAP instead of MODE_FILE
|
|
339
|
+
- Preserve our path adjustments
|
|
340
|
+
- Update expected error messages if needed
|
|
341
|
+
|
|
342
|
+
4. Document changes in `test/maxmind/README.md`
|
|
343
|
+
|
|
344
|
+
## Submitting Changes
|
|
345
|
+
|
|
346
|
+
### Before Submitting a Pull Request
|
|
347
|
+
|
|
348
|
+
1. **Ensure all tests pass**:
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
bundle exec rake test
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
2. **Run code quality checks**:
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
bundle exec rubocop
|
|
358
|
+
cd ext/maxmind_db_rust && cargo clippy && cargo fmt --check
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
3. **Update documentation** if needed:
|
|
362
|
+
- README.md for user-facing changes
|
|
363
|
+
- CHANGELOG.md for notable changes
|
|
364
|
+
- Code comments for complex logic
|
|
365
|
+
|
|
366
|
+
4. **Rebase on main**:
|
|
367
|
+
```bash
|
|
368
|
+
git fetch origin
|
|
369
|
+
git rebase origin/main
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Pull Request Process
|
|
373
|
+
|
|
374
|
+
1. **Push your branch**:
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
git push origin feature/my-new-feature
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
2. **Create a pull request** on GitHub with:
|
|
381
|
+
- Clear description of changes
|
|
382
|
+
- Reference to related issues
|
|
383
|
+
- Screenshots/examples if applicable
|
|
384
|
+
- Test results
|
|
385
|
+
|
|
386
|
+
3. **Address review feedback**:
|
|
387
|
+
- Make requested changes
|
|
388
|
+
- Push updates to the same branch
|
|
389
|
+
- Respond to comments
|
|
390
|
+
|
|
391
|
+
4. **Wait for approval** and merge
|
|
392
|
+
|
|
393
|
+
## Release Process
|
|
394
|
+
|
|
395
|
+
### Version Numbering
|
|
396
|
+
|
|
397
|
+
We follow [Semantic Versioning](https://semver.org/):
|
|
398
|
+
|
|
399
|
+
- **MAJOR**: Incompatible API changes
|
|
400
|
+
- **MINOR**: Backward-compatible functionality additions
|
|
401
|
+
- **PATCH**: Backward-compatible bug fixes
|
|
402
|
+
|
|
403
|
+
### Creating a Release
|
|
404
|
+
|
|
405
|
+
1. **Update version** in `maxmind-db-rust.gemspec`:
|
|
406
|
+
|
|
407
|
+
```ruby
|
|
408
|
+
s.version = '0.2.0'
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
2. **Update CHANGELOG.md**:
|
|
412
|
+
|
|
413
|
+
```markdown
|
|
414
|
+
## [0.2.0] - 2025-01-15
|
|
415
|
+
|
|
416
|
+
### Added
|
|
417
|
+
|
|
418
|
+
- New feature X
|
|
419
|
+
|
|
420
|
+
### Fixed
|
|
421
|
+
|
|
422
|
+
- Bug fix Y
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
3. **Commit version bump**:
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
git add maxmind-db-rust.gemspec CHANGELOG.md
|
|
429
|
+
git commit -m "Bump version to 0.2.0"
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
4. **Create and push tag**:
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
git tag -a v0.2.0 -m "Release version 0.2.0"
|
|
436
|
+
git push origin main
|
|
437
|
+
git push origin v0.2.0
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
5. **Build and publish gem**:
|
|
441
|
+
```bash
|
|
442
|
+
bundle exec rake build
|
|
443
|
+
gem push pkg/maxmind-db-rust-0.2.0.gem
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
## Performance Considerations
|
|
447
|
+
|
|
448
|
+
### Benchmarking
|
|
449
|
+
|
|
450
|
+
When making performance-related changes:
|
|
451
|
+
|
|
452
|
+
1. **Create benchmark script**:
|
|
453
|
+
|
|
454
|
+
```ruby
|
|
455
|
+
require 'benchmark'
|
|
456
|
+
require 'maxmind/db/rust'
|
|
457
|
+
|
|
458
|
+
reader = MaxMind::DB::Rust::Reader.new('path/to/db.mmdb')
|
|
459
|
+
ips = File.readlines('test_ips.txt').map(&:strip)
|
|
460
|
+
|
|
461
|
+
Benchmark.bm do |x|
|
|
462
|
+
x.report("lookups:") do
|
|
463
|
+
100_000.times { reader.get(ips.sample) }
|
|
464
|
+
end
|
|
465
|
+
end
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
2. **Compare before and after** your changes
|
|
469
|
+
|
|
470
|
+
3. **Document results** in PR description
|
|
471
|
+
|
|
472
|
+
### Optimization Tips
|
|
473
|
+
|
|
474
|
+
- Use MODE_MMAP for best performance (default)
|
|
475
|
+
- Release GIL during I/O operations (already implemented)
|
|
476
|
+
- Minimize Ruby object allocations in hot paths
|
|
477
|
+
- Use Arc for thread-safe sharing instead of cloning
|
|
478
|
+
|
|
479
|
+
## Getting Help
|
|
480
|
+
|
|
481
|
+
- **Issues**: https://github.com/oschwald/maxmind-db-rust-ruby/issues
|
|
482
|
+
- **Discussions**: Use GitHub Discussions for questions
|
|
483
|
+
- **MaxMind Docs**: https://maxmind.github.io/MaxMind-DB/
|
|
484
|
+
|
|
485
|
+
## Code of Conduct
|
|
486
|
+
|
|
487
|
+
- Be respectful and inclusive
|
|
488
|
+
- Provide constructive feedback
|
|
489
|
+
- Focus on the code, not the person
|
|
490
|
+
- Help others learn and grow
|
|
491
|
+
|
|
492
|
+
## License
|
|
493
|
+
|
|
494
|
+
By contributing, you agree that your contributions will be licensed under the ISC License.
|
|
495
|
+
|
|
496
|
+
Thank you for contributing! 🎉
|
data/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Gregory Oschwald
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|