Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various cleanups from anguslees@ #1

Merged
merged 1 commit into from
Jun 10, 2021
Merged

Various cleanups from anguslees@ #1

merged 1 commit into from
Jun 10, 2021

Conversation

gyuho
Copy link
Owner

@gyuho gyuho commented May 24, 2021

More idiomatic Rust :)

Split channel sender and receiver into two clear owners.

Replace sync crossbeam with async tokio channels, so we don't hold a
synchronous lock over async await.

Simplify applier start/stop lifecycle with RAII pattern (could do more here).

Pass owned echo::Manager to apply_async rather than Arc reference.

Use ? operator and early-return to refactor some deeply nested code,
particularly in server::handle_request.

Notifier: Replace async RwLock<> with simpler sync Arc<Mutex<>>
because these locks don't need to be held over async await.

echo::Manager: Use ownership (&mut) to assert mutual exclusion
rather than a lock.

echo::Request: Treat omitted message as equivalent to
message == "", to better match golang omitempty semantics.

Split channel sender and receiver into two clear owners.

Replace sync crossbeam with async tokio channels, so we don't hold a
synchronous lock over async await.

Simplify applier start/stop lifecycle with RAII pattern (could do more here).

Pass owned `echo::Manager` to `apply_async` rather than `Arc` reference.

Use `?` operator and early-return to refactor some deeply nested code,
particularly in `server::handle_request`.

`Notifier`: Replace async `RwLock<>` with simpler sync `Arc<Mutex<>>`
because these locks don't need to be held over async await.

`echo::Manager`: Use ownership (`&mut`) to assert mutual exclusion
rather than a lock.

`echo::Request`: Treat omitted `message` as equivalent to
`message == ""`, to better match golang `omitempty` semantics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants