use fx lifecycle hooks to start and stop services
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6.9k
- Forks
- 1.3k
- Avg merge
- 13d 21h
- Merged PRs (30d)
- 1
Description
Starting and stopping services on the host has long been a pain point. By using [fx's lifecycle hooks](https://uber-go.github.io/fx/lifecycle.html#lifecycle-hooks) we could potentially dramatically simplify our code base.
This is the `Close` logic in the `BasicHost`: https://github.com/libp2p/go-libp2p/blob/c48e78f0733d8bdb45ab766352e490b903983977/p2p/host/basic/basic_host.go#L972-L1011
There also exist wrapped hosts _only_ for hooking into the `Close` method, for example here: https://github.com/libp2p/go-libp2p/blob/c48e78f0733d8bdb45ab766352e490b903983977/p2p/host/autorelay/host.go#L7-L15
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Close logic in p2p/host/basic/basic_host.go and the wrapper in p2p/host/autorelay/host.go, then read the linked fx lifecycle hooks documentation. Trace how these hosts currently start and stop services and identify the lifecycle paths that need consolidation. Done means the service lifecycle uses fx hooks while preserving the existing start and stop behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100