Skip to content

Commit 5cb445e

Browse files
committed
Releasing 0.14.0
- New experimental TLS support ("tls" feature, disabled by default)
1 parent b55afde commit 5cb445e

File tree

8 files changed

+64
-34
lines changed

8 files changed

+64
-34
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v3
2222
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
23-
- run: cargo build --verbose
24-
- run: cargo test --verbose
23+
- run: cargo build --all-features --verbose
24+
- run: cargo test --all-features --verbose

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rustygear/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rustygear"
33
description = "Client library for communicating via the gearman protocol"
44
repository = "https://github.com/SpamapS/rustygear"
5-
version = "0.13.0"
5+
version = "0.14.0"
66
authors = ["Clint Byrum <clint@fewbar.com>"]
77
license = "Apache-2.0"
88
edition = "2018"

rustygear/examples/multiserver.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
77
env_logger::init();
88
let mut client = Client::new()
99
.add_server("127.0.0.1:4730")
10-
.add_server("127.0.0.1:4731").connect().await?;
10+
.add_server("127.0.0.1:4731")
11+
.connect()
12+
.await?;
1113
println!("Connected!");
1214
println!("Echo: {:?}", client.echo(b"blah").await);
1315
let mut jobs = Vec::new();
1416
for x in 0..10 {
1517
let payload = format!("payload{}", x);
1618
jobs.push(client.submit("reverse", payload.as_bytes()).await?);
1719
}
18-
println!("Submitted {}", jobs.iter().map(|j| format!("{}", j)).collect::<String>());
20+
println!(
21+
"Submitted {}",
22+
jobs.iter().map(|j| format!("{}", j)).collect::<String>()
23+
);
1924
for job in jobs.iter_mut() {
2025
let response = job.response().await;
21-
println!("Response for [{:?}] is [{:?}]",
22-
job.handle(),
23-
response)
24-
};
26+
println!("Response for [{:?}] is [{:?}]", job.handle(), response)
27+
}
2528
Ok(())
2629
}

rustygear/src/clientdata.rs

+39-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
use std::{collections::HashMap, sync::{Arc, Mutex, MutexGuard, RwLock}};
1+
use std::{
2+
collections::HashMap,
3+
sync::{Arc, Mutex, MutexGuard, RwLock},
4+
};
25

36
use bytes::Bytes;
4-
use tokio::sync::mpsc::{Sender, Receiver, channel};
7+
use tokio::sync::mpsc::{channel, Receiver, Sender};
58

6-
use crate::{client::{WorkUpdate, WorkerJob, JobStatus}, conn::ServerHandle};
9+
use crate::{
10+
client::{JobStatus, WorkUpdate, WorkerJob},
11+
conn::ServerHandle,
12+
};
713

814
pub type JobCreated = ServerHandle;
915

@@ -55,7 +61,10 @@ pub struct ClientData {
5561

5662
impl Clone for ClientData {
5763
fn clone(&self) -> Self {
58-
Self { receivers: self.receivers.clone(), senders: self.senders.clone() }
64+
Self {
65+
receivers: self.receivers.clone(),
66+
senders: self.senders.clone(),
67+
}
5968
}
6069
}
6170

@@ -67,7 +76,7 @@ impl ClientReceivers {
6776
error_rx: Receiver<(Bytes, Bytes)>,
6877
worker_job_rx: Receiver<WorkerJob>,
6978
) -> ClientReceivers {
70-
ClientReceivers{
79+
ClientReceivers {
7180
echo_rx: echo_rx,
7281
job_created_rx: job_created_rx,
7382
status_res_rx: status_res_rx,
@@ -87,8 +96,20 @@ impl ClientData {
8796
let (error_tx, error_rx) = channel(CLIENT_CHANNEL_BOUND_SIZE);
8897
let (worker_job_tx, worker_job_rx) = channel(CLIENT_CHANNEL_BOUND_SIZE);
8998
ClientData {
90-
receivers: Arc::new(Mutex::new(ClientReceivers::new(echo_rx, job_created_rx, status_res_rx, error_rx, worker_job_rx))),
91-
senders: Arc::new(RwLock::new(ClientSenders::new(echo_tx, job_created_tx, status_res_tx, error_tx, worker_job_tx))),
99+
receivers: Arc::new(Mutex::new(ClientReceivers::new(
100+
echo_rx,
101+
job_created_rx,
102+
status_res_rx,
103+
error_rx,
104+
worker_job_rx,
105+
))),
106+
senders: Arc::new(RwLock::new(ClientSenders::new(
107+
echo_tx,
108+
job_created_tx,
109+
status_res_tx,
110+
error_tx,
111+
worker_job_tx,
112+
))),
92113
}
93114
}
94115

@@ -125,7 +146,11 @@ impl ClientData {
125146
}
126147

127148
pub fn set_sender_by_handle(&mut self, handle: ServerHandle, tx: Sender<WorkUpdate>) {
128-
self.senders.write().unwrap().senders_by_handle.insert(handle, tx);
149+
self.senders
150+
.write()
151+
.unwrap()
152+
.senders_by_handle
153+
.insert(handle, tx);
129154
}
130155

131156
pub fn get_jobs_tx_by_func(&self, func: &Vec<u8>) -> Option<Sender<WorkerJob>> {
@@ -136,6 +161,10 @@ impl ClientData {
136161
}
137162

138163
pub fn set_jobs_tx_by_func(&mut self, func: Vec<u8>, tx: Sender<WorkerJob>) {
139-
self.senders.write().unwrap().jobs_tx_by_func.insert(func, tx);
164+
self.senders
165+
.write()
166+
.unwrap()
167+
.jobs_tx_by_func
168+
.insert(func, tx);
140169
}
141-
}
170+
}

rustygeard/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustygeard"
33
description = "An experimental, full-featured gearman server."
4-
version = "0.13.0"
4+
version = "0.14.0"
55
authors = ["Clint Byrum <clint@fewbar.com>"]
66
license = "Apache-2.0"
77
edition = "2018"
@@ -13,7 +13,7 @@ tls = ["dep:tokio-rustls","dep:rustls-pemfile","rustygear/tls"]
1313

1414
[dependencies]
1515
bytes = ">=1.1.0"
16-
rustygear = { path = "../rustygear" , version = ">= 0.13.0" }
16+
rustygear = { path = "../rustygear" , version = ">= 0.14.0" }
1717
log = ">=0.4.8"
1818
env_logger = { version = ">=0.10.1" , features = ["auto-color", "humantime"] }
1919
tokio = { version = "1.37.0", features = ["full"] }

rustygeard/src/admin.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use std::net::SocketAddr;
33
use bytes::{BufMut, Bytes, BytesMut};
44

55
use rustygear::codec::Packet;
6-
use rustygear::constants::{PRIORITY_HIGH, PRIORITY_NORMAL, PRIORITY_LOW};
6+
use rustygear::constants::{PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_NORMAL};
77

88
use crate::queues::SharedJobStorage;
9+
use crate::service::{GearmanService, WorkersByConnId};
910
use crate::worker::{SharedWorkers, Wake};
10-
use crate::service::{WorkersByConnId, GearmanService};
1111

1212
pub fn admin_command_status(storage: SharedJobStorage, workers: SharedWorkers) -> Packet {
1313
let mut response = BytesMut::with_capacity(1024 * 1024); // XXX Wild guess.
@@ -83,19 +83,17 @@ pub fn admin_command_workers(workers: WorkersByConnId) -> Packet {
8383
pub fn admin_command_shutdown(service: &GearmanService, addr: &SocketAddr) -> Packet {
8484
// For now we only allow this on localhost.
8585
if match addr {
86-
SocketAddr::V6(addr) => {
87-
addr.to_string().starts_with("[::1]")
88-
},
89-
SocketAddr::V4(addr) => {
90-
addr.to_string().starts_with("127.0.0.")
91-
}
86+
SocketAddr::V6(addr) => addr.to_string().starts_with("[::1]"),
87+
SocketAddr::V4(addr) => addr.to_string().starts_with("127.0.0."),
9288
} {
9389
service.shutdown_service();
94-
return Packet::new_text_res(Bytes::from("BYE\n"))
90+
return Packet::new_text_res(Bytes::from("BYE\n"));
9591
}
9692
return Packet::new_text_res(Bytes::from(format!("ERR: Not allowed from {:?}\n", addr)));
9793
}
9894

9995
pub fn admin_command_unknown() -> Packet {
100-
Packet::new_text_res(Bytes::from_static(b"ERR UNKNOWN_COMMAND Unknown+server+command\n"))
96+
Packet::new_text_res(Bytes::from_static(
97+
b"ERR UNKNOWN_COMMAND Unknown+server+command\n",
98+
))
10199
}

rustygeard/src/worker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ extern crate wrappinghashset;
33
use self::wrappinghashset::{Iter, WrappingHashSet};
44

55
use std::collections::{HashMap, HashSet};
6-
use std::sync::{Arc, Mutex};
76
use std::net::SocketAddr;
7+
use std::sync::{Arc, Mutex};
88

99
use bytes::Bytes;
1010

0 commit comments

Comments
 (0)