Skip to content

[post] Graceful shutdown a http server from its handler in Rust warp #51

Open
@at15

Description

@at15

Type

  • request post from @at15

Related

Description

NOTE: The up to date note is in http://doc/github.com/at15/rust-learning/lib/warp/

I want to have a /shutdown route that allows me to shutdown a http sever by hitting that endpoint.
However it is not that easy in Rust compared with Go (create a context/channel for cancellation, start two go routine, one blocks on server, one wait for cancel). Rust code is harder because it uses ownership instead of GC and has mutability rules.

The post will contain the following

  • how to do graceful shutdown in Go
  • the iterations of getting the shutdown logic working in Rust
    • closure trait Fn, FnMut, FnOnce
    • channel (in tokio)
    • passing a channel to Fn closure
    • mutex

Update

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions