mirror of
https://github.com/bspeice/aeron-rs
synced 2024-12-21 21:38:09 -05:00
Start work on the client context
This commit is contained in:
parent
646d58fd1b
commit
1fdf79af8b
@ -6,6 +6,8 @@ edition = "2018"
|
||||
repository = "https://github.com/bspeice/aeron-rs"
|
||||
readme = "README.md"
|
||||
license = "Apache-2.0"
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "bspeice/aeron-rs", branch = "master" }
|
||||
maintenance = { status = "actively-developed" }
|
||||
|
||||
|
@ -2,4 +2,8 @@
|
||||
|
||||
![](https://img.shields.io/travis/bspeice/aeron-rs?style=flat-square)
|
||||
|
||||
A Rust port of the [Aeron client](https://github.com/real-logic/Aeron).
|
||||
<!-- cargo-sync-readme start -->
|
||||
|
||||
[Aeron](https://github.com/real-logic/aeron) client for Rust
|
||||
|
||||
<!-- cargo-sync-readme end -->
|
||||
|
@ -1,2 +1,3 @@
|
||||
#include <stddef.h>
|
||||
#include <aeron_driver_context.h>
|
||||
#include <aeronmd.h>
|
||||
|
44
src/context.rs
Normal file
44
src/context.rs
Normal file
@ -0,0 +1,44 @@
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
const DEFAULT_MEDIA_DRIVER_TIMEOUT_MS: u16 = 10_000;
|
||||
const DEFAULT_RESOURCE_LINGER_MS: u16 = 5_000;
|
||||
|
||||
pub struct Context {
|
||||
aeron_dir: PathBuf,
|
||||
media_driver_timeout_ms: i32,
|
||||
resource_linger_timeout_ms: i32,
|
||||
use_conductor_agent_invoker: bool,
|
||||
pre_touch_mapped_memory: bool,
|
||||
}
|
||||
|
||||
impl Context {
|
||||
pub fn get_user_name() -> String {
|
||||
env::var("USER")
|
||||
.or_else(|_| env::var("USERNAME"))
|
||||
.unwrap_or("default".to_string())
|
||||
}
|
||||
|
||||
pub fn default_aeron_path() -> PathBuf {
|
||||
let base_path = if cfg!(target_os = "linux") {
|
||||
PathBuf::from("/dev/shm")
|
||||
} else {
|
||||
// Uses TMPDIR on Unix-like, and GetTempPath on Windows
|
||||
env::temp_dir()
|
||||
};
|
||||
|
||||
base_path.join(format!("aeron-{}", Context::get_user_name()))
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Context {
|
||||
fn default() -> Self {
|
||||
Context {
|
||||
aeron_dir: Context::default_aeron_path(),
|
||||
media_driver_timeout_ms: DEFAULT_MEDIA_DRIVER_TIMEOUT_MS.into(),
|
||||
resource_linger_timeout_ms: DEFAULT_RESOURCE_LINGER_MS.into(),
|
||||
use_conductor_agent_invoker: false,
|
||||
pre_touch_mapped_memory: false,
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
//! Aeron client for Rust
|
||||
//! [Aeron](https://github.com/real-logic/aeron) client for Rust
|
||||
#![deny(missing_docs)]
|
||||
|
||||
mod context;
|
||||
|
||||
/// Retrieve the C library version in (major, minor, patch) format
|
||||
pub fn aeron_version() -> (u32, u32, u32) {
|
||||
unsafe {
|
||||
|
Loading…
Reference in New Issue
Block a user