Skip to content

Commit

Permalink
Merge branch 'main' into feat/ent-batch-jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhoo committed Feb 18, 2024
2 parents f8dae7d + 0bd2ab0 commit 80749d4
Show file tree
Hide file tree
Showing 23 changed files with 437 additions and 46 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ updates:
update-types:
- "version-update:semver-patch"
- "version-update:semver-minor"
- package-ecosystem: docker
directory: docker
schedule:
interval: weekly
22 changes: 20 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ jobs:
components: rustfmt
- name: cargo fmt --check
run: cargo fmt --check
# This is currently a dedicated job due to the rustfmt's `group_imports` configuration
# option being available on the nightly channel only as of February 2024.
# Once stabilized, can be merged with the `stable / fmt` job in this workflow.
# See: https://github.com/rust-lang/rustfmt/issues/5083
imports:
runs-on: ubuntu-latest
name: nightly / fmt (import grouping)
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: cargo +nightly fmt -- --config group_imports=one --check
run: cargo +nightly fmt -- --config group_imports=one --check
clippy:
runs-on: ubuntu-latest
name: ${{ matrix.toolchain }} / clippy
Expand All @@ -55,9 +72,10 @@ jobs:
toolchain: ${{ matrix.toolchain }}
components: clippy
- name: cargo clippy
uses: actions-rs/clippy-check@v1
uses: giraffate/clippy-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
reporter: 'github-pr-check'
github_token: ${{ secrets.GITHUB_TOKEN }}
doc:
# run docs generation on nightly rather than stable. This enables features like
# https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an
Expand Down
29 changes: 26 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,27 @@ jobs:
- name: cargo test (w/o integrations)
run: cargo test --locked --all-features --all-targets
coverage:
# use llvm-cov to build and collect coverage and outputs in a format that is compatible with
# codecov.io
# use llvm-cov to build and collect coverage and outputs in a format that
# is compatible with codecov.io
#
# note that codecov as of v4 requires that CODECOV_TOKEN from
#
# https://app.codecov.io/gh/<user or org>/<project>/settings
#
# is set in two places on your repo:
#
# - https://github.com/jonhoo/guardian/settings/secrets/actions
# - https://github.com/jonhoo/guardian/settings/secrets/dependabot
#
# (the former is needed for codecov uploads to work with Dependabot PRs)
#
# PRs coming from forks of your repo will not have access to the token, but
# for those, codecov allows uploading coverage reports without a token.
# it's all a little weird and inconvenient. see
#
# https://github.com/codecov/feedback/issues/112
#
# for lots of more discussion
runs-on: ubuntu-latest
name: ubuntu / stable / coverage
steps:
Expand All @@ -146,10 +165,14 @@ jobs:
run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info
env: # set this explicitly so integration tests will run
FAKTORY_URL: tcp://127.0.0.1:7419
- name: Record Rust version
run: echo "RUST=$(rustc --version)" >> "$GITHUB_ENV"
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS,RUST
services:
faktory:
image: contribsys/faktory:latest
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/tls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will make use of Faktory put behind NGINX to test
# the crate's tls feature (see docker dir in the project's root)
permissions:
contents: read
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: tls
jobs:
test:
runs-on: ubuntu-latest
name: ubuntu-latest / stable / tls
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Launch Faktory behind NGINX
run: docker compose -f docker/compose.yml up -d --build
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: Run tests
env:
FAKTORY_URL_SECURE: tcp://localhost:17419
run: cargo test --locked --features tls --test tls
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ repository = "https://github.com/jonhoo/faktory-rs.git"
keywords = ["faktory", "api-bindings", "work-server", "job-server"]
categories = ["api-bindings", "asynchronous", "network-programming"]

exclude = [".github", "docker", ".gitignore", "Makefile"]

[features]
default = []
tls = ["native-tls"]
Expand Down
22 changes: 19 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FAKTORY_HOST=127.0.0.1
FAKTORY_HOST=localhost
FAKTORY_PORT=7419
FAKTORY_PORT_SECURE=17419
FAKTORY_PORT_UI=7420

.PHONY: check
check:
cargo fmt --check
cargo clippy
cargo d --no-deps --all-features
cargo +nightly fmt -- --config group_imports=one --check

.PHONY: doc
doc:
Expand All @@ -26,8 +28,17 @@ faktory:
faktory/kill:
docker stop faktory

README.md: README.tpl src/lib.rs
cargo readme > README.md
.PHONY: faktory/tls
faktory/tls:
docker compose -f docker/compose.yml up -d --build

.PHONY: faktory/tls/kill
faktory/tls/kill:
docker compose -f docker/compose.yml down

.PHONY: sort
sort:
cargo +nightly fmt -- --config group_imports=one

.PHONY: test
test:
Expand All @@ -41,6 +52,11 @@ test/doc:
test/e2e:
FAKTORY_URL=tcp://${FAKTORY_HOST}:${FAKTORY_PORT} cargo test --locked --all-features --all-targets

.PHONY: test/e2e/tls
test/e2e/tls:
FAKTORY_URL_SECURE=tcp://${FAKTORY_HOST}:${FAKTORY_PORT_SECURE} \
cargo test --locked --features tls --test tls

.PHONY: test/load
test/load:
cargo run --release --features binaries
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ Please note that setting "FAKTORY_URL" environment variable is required for e2e
Provided you have [make](https://www.gnu.org/software/make/#download) installed and `docker` daemon running,
you can launch a `Faktory` container with `make faktory` command. After that, hit `make test/e2e` to run the end-to-end test suite.
Remove the container with `make faktory/kill`, if it's no longer needed.

To run end-to-end tests for the crate's `tls` feature, ensure you've got the [`compose`](https://docs.docker.com/compose/install/) docker plugin installed.
Run `make faktory/tls` to spin up `Faktory` behind `NGINX` with ssl termination, then run `make test/e2e/tls`. To remove the containers, hit `make faktory/tls/kill`.
25 changes: 0 additions & 25 deletions README.tpl

This file was deleted.

21 changes: 21 additions & 0 deletions docker/certs/faktory.local.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIDazCCAlMCFAxQwXkfT4M84/fevISct//qQskRMA0GCSqGSIb3DQEBCwUAMHEx
CzAJBgNVBAYTAlVaMREwDwYDVQQIDAhUYXNoa2VudDERMA8GA1UEBwwIVGFzaGtl
bnQxEzARBgNVBAoMCmZha3RvcnktcnMxEzARBgNVBAsMCmZha3RvcnktcnMxEjAQ
BgNVBAMMCWxvY2FsaG9zdDAgFw0yNDAyMDMyMDI1MDlaGA8zMDA0MDQwNjIwMjUw
OVowcTELMAkGA1UEBhMCVVoxETAPBgNVBAgMCFRhc2hrZW50MREwDwYDVQQHDAhU
YXNoa2VudDETMBEGA1UECgwKZmFrdG9yeS1yczETMBEGA1UECwwKZmFrdG9yeS1y
czESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEA4ektheqTRy+eHn9j22AxGHqtg/elEiZC0UCLX51ysEkhnLLvFlVFtzd7
q+nx1PNiHdH5i/TjdAYrXAZhKU/k2YfrgCyOjm/XxSw7ujXPP+cWOmdRYTexT9o7
Yrg3ZYMniJbbTl8j37dieXHaO7FHAvpww1q/nbQkwD/1WqK1ggQY/OZ38wpUvsws
9LA7shuXdGnjAXunnRGEzZ2EG6T5hYw0PFL+2CHwr0lqNbCur8wu99t4ED9/vfLG
0TWRQwSnApyjHy89rn5Ze3vOiNzcBW778oZxwvzriEmbQQg6RxKE19AlaiV4+n5S
woAi8Ji69BKRUSlxRhW6eX4ABV2eOwIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQDS
EXuIvVx27LyWlIhfY6vwSWqeUoRXmMFpiBNTTvvHQKlJzLlDyn1b+CqHvMdE9RZh
FI5shZkiqtRRTUGVHB4o0ntwCQmWyV/5FQQ6EYs/bHXUcN2vt1XuU7WK4fRafPPu
snYDgg0TmpGvm+J8W64TfJogWqpPsnT4pOF+aNqW88TTs1JUnNFDBQmw2QKBK+AH
+V4zhpCjVXpKtVMTnDWHQfJh4whelD18lU1jPCbzQrRs2hQWQvtzKWi0YCYc1IXl
4E6eIOHRuiUl/mE3p3f2CGJIwxgrMuxN07ncnwVXBPCaVzSLWJHy0G61mFKH5R/7
42EC7S/POk5GtzkMJ5Du
-----END CERTIFICATE-----
28 changes: 28 additions & 0 deletions docker/certs/faktory.local.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDh6S2F6pNHL54e
f2PbYDEYeq2D96USJkLRQItfnXKwSSGcsu8WVUW3N3ur6fHU82Id0fmL9ON0Bitc
BmEpT+TZh+uALI6Ob9fFLDu6Nc8/5xY6Z1FhN7FP2jtiuDdlgyeIlttOXyPft2J5
cdo7sUcC+nDDWr+dtCTAP/VaorWCBBj85nfzClS+zCz0sDuyG5d0aeMBe6edEYTN
nYQbpPmFjDQ8Uv7YIfCvSWo1sK6vzC7323gQP3+98sbRNZFDBKcCnKMfLz2ufll7
e86I3NwFbvvyhnHC/OuISZtBCDpHEoTX0CVqJXj6flLCgCLwmLr0EpFRKXFGFbp5
fgAFXZ47AgMBAAECggEAJjyV4G86O1fDbw0HxUdMOAT3nnkJfv9r2sgObwISueS+
5CtjDUgkkyS4cXoY3P7O0hZKoxYxc19h8mMACgKETQ9U3G5uOIyUnEJm35cg+4Ns
/ziijQ5knAvndkeQ1MU0qUlDWEoBI+oBqGWNVwIj70ydTmtrOFGX0NRi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b
-----END PRIVATE KEY-----
24 changes: 24 additions & 0 deletions docker/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Since `dependabot` does not yet support `compose` files,
# we are using "proxy" dockerfiles, as per instructions:
# https://github.com/dependabot/dependabot-core/issues/390#issuecomment-1062170379

services:
faktory:
build:
context: .
dockerfile: faktory.Dockerfile
command: "/faktory -b :7419 -w :7420"
nginx:
depends_on:
- faktory
build:
context: .
dockerfile: nginx.Dockerfile
ports:
- "127.0.0.1:7419:7419"
- "127.0.0.1:7420:7420"
- "127.0.0.1:17419:17419"
- "127.0.0.1:17420:17420"
volumes:
- ./nginx:/etc/nginx:ro
- ./certs:/etc/ssl/certs:ro
1 change: 1 addition & 0 deletions docker/faktory.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM contribsys/faktory:1.8.0
1 change: 1 addition & 0 deletions docker/nginx.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM nginx:1.25-alpine
37 changes: 37 additions & 0 deletions docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
worker_processes 4;

stream {
server {
listen 7419 reuseport;
proxy_pass faktory:7419;
}

server {
listen 17419 ssl reuseport;
ssl_certificate /etc/ssl/certs/faktory.local.crt;
ssl_certificate_key /etc/ssl/certs/faktory.local.key;
proxy_pass faktory:7419;
}
}

http {
server {
listen 7420 reuseport;
location / {
proxy_pass http://faktory:7420;
}
}

server {
listen 17420 ssl reuseport;
ssl_certificate /etc/ssl/certs/faktory.local.crt;
ssl_certificate_key /etc/ssl/certs/faktory.local.key;
location / {
proxy_pass http://faktory:7420;
}
}
}

events {
worker_connections 1024;
}
12 changes: 8 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
//! use faktory::{Producer, Job};
//! let mut p = Producer::connect(None).unwrap();
//! p.enqueue(Job::new("foobar", vec!["z"])).unwrap();
//!
//! let (enqueued_count, errors) = p.enqueue_many(vec![Job::new("foobar", vec!["z"]), Job::new("foobar", vec!["z"])]).unwrap();
//! assert_eq!(enqueued_count, 2);
//! assert_eq!(errors, None);
//! ```
//!
//! If you want to **accept** jobs from Faktory, use `Consumer`.
Expand Down Expand Up @@ -69,10 +73,6 @@ mod proto;
#[cfg(feature = "tls")]
#[cfg_attr(docsrs, doc(cfg(feature = "tls")))]
mod tls;
#[cfg(feature = "tls")]
#[cfg_attr(docsrs, doc(cfg(feature = "tls")))]
pub use tls::TlsStream;

pub use crate::consumer::{Consumer, ConsumerBuilder};
pub use crate::error::Error;
pub use crate::producer::Producer;
Expand All @@ -87,3 +87,7 @@ pub mod ent {
ProgressUpdate, ProgressUpdateBuilder,
};
}

#[cfg(feature = "tls")]
#[cfg_attr(docsrs, doc(cfg(feature = "tls")))]
pub use tls::TlsStream;
Loading

0 comments on commit 80749d4

Please sign in to comment.