prometheus-client-mmap 1.0.0-x86_64-darwin → 1.0.1-x86_64-darwin
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 +4 -4
- data/ext/fast_mmaped_file_rs/src/file_info.rs +51 -1
- data/lib/2.7/fast_mmaped_file_rs.bundle +0 -0
- data/lib/3.0/fast_mmaped_file_rs.bundle +0 -0
- data/lib/3.1/fast_mmaped_file_rs.bundle +0 -0
- data/lib/3.2/fast_mmaped_file_rs.bundle +0 -0
- data/lib/prometheus/client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be3b67bb7ddbb4629ec612dc55a2f9342d8a41c9290cc6da64edf8d816c0c5f5
|
4
|
+
data.tar.gz: cb98fa2e2758f5acffb31c0379c406dc6d7d40de200101dc63cc4dbc6a4d3d86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b568bda8be9e2ca19e9d6a645953ab7eff7b11477b5008615a263e0d43dc2ba567e899554c10fdc65a31f257c1dedf92cadf4a51be3500b770e57facf168396c
|
7
|
+
data.tar.gz: 965217cb2aa20f781f513b8135636e153b33d97c848064649e24ba4178f0b9c1ab1bbd123a54d05d268cb5e8bd3caf4ee138f75ec6f08535178b4125ce7d2947
|
@@ -91,6 +91,11 @@ impl FileInfo {
|
|
91
91
|
|
92
92
|
match self.file.read_to_end(buf) {
|
93
93
|
Ok(n) if n == self.len => Ok(()),
|
94
|
+
// A worker may expand the file between our `stat` and `read`, no harm done.
|
95
|
+
Ok(n) if n > self.len => {
|
96
|
+
self.len = n;
|
97
|
+
Ok(())
|
98
|
+
}
|
94
99
|
Ok(_) => Err(MmapError::io(
|
95
100
|
"read",
|
96
101
|
&self.path,
|
@@ -106,6 +111,8 @@ mod test {
|
|
106
111
|
use magnus::{eval, RArray, Symbol};
|
107
112
|
use rand::{thread_rng, Rng};
|
108
113
|
use sha2::{Digest, Sha256};
|
114
|
+
use std::fs;
|
115
|
+
use std::io::Write;
|
109
116
|
|
110
117
|
use super::*;
|
111
118
|
use crate::testhelper::TestFile;
|
@@ -165,7 +172,7 @@ mod test {
|
|
165
172
|
|
166
173
|
let mut info = FileInfo {
|
167
174
|
file,
|
168
|
-
path,
|
175
|
+
path: path.clone(),
|
169
176
|
len: buf.len(),
|
170
177
|
multiprocess_mode: Symbol::new("puma"),
|
171
178
|
type_: Symbol::new("max"),
|
@@ -187,4 +194,47 @@ mod test {
|
|
187
194
|
|
188
195
|
assert_eq!(in_hash, out_hash, "content hashes");
|
189
196
|
}
|
197
|
+
|
198
|
+
#[test]
|
199
|
+
fn test_read_from_file_resized() {
|
200
|
+
let _cleanup = unsafe { magnus::embed::init() };
|
201
|
+
let ruby = magnus::Ruby::get().unwrap();
|
202
|
+
crate::init(&ruby).unwrap();
|
203
|
+
|
204
|
+
const BUF_LEN: usize = 1 << 14; // 16KiB
|
205
|
+
|
206
|
+
// Create a buffer with random data.
|
207
|
+
let mut buf = vec![0u8; BUF_LEN];
|
208
|
+
thread_rng().fill(buf.as_mut_slice());
|
209
|
+
|
210
|
+
let TestFile {
|
211
|
+
file,
|
212
|
+
path,
|
213
|
+
dir: _dir,
|
214
|
+
} = TestFile::new(&buf);
|
215
|
+
|
216
|
+
let mut info = FileInfo {
|
217
|
+
file,
|
218
|
+
path: path.clone(),
|
219
|
+
len: buf.len(),
|
220
|
+
multiprocess_mode: Symbol::new("puma"),
|
221
|
+
type_: Symbol::new("max"),
|
222
|
+
pid: "worker-0_0".to_string(),
|
223
|
+
};
|
224
|
+
|
225
|
+
let mut resized_file = fs::OpenOptions::new()
|
226
|
+
.write(true)
|
227
|
+
.append(true)
|
228
|
+
.open(path)
|
229
|
+
.unwrap();
|
230
|
+
|
231
|
+
// Write data to file after it has been `stat`ed in the
|
232
|
+
// constructor.
|
233
|
+
resized_file.write_all(&[1; 1024]).unwrap();
|
234
|
+
|
235
|
+
let mut out_buf = Vec::new();
|
236
|
+
info.read_from_file(&mut out_buf).unwrap();
|
237
|
+
|
238
|
+
assert_eq!(BUF_LEN + 1024, info.len, "resized file updated len");
|
239
|
+
}
|
190
240
|
}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus-client-mmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: x86_64-darwin
|
6
6
|
authors:
|
7
7
|
- Tobias Schmidt
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2023-
|
14
|
+
date: 2023-12-04 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rb_sys
|