grpc / grpc/grpc-java

Feature: Lifecycle events for service implementations

Open
#3,449 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
12.1k
Forks
4k
Avg merge
2d 17h
Merged PRs (30d)
37

Description

I'd like my service implementations to be notified of server lifecycle events for server start and shutdown. These operations could be used to warm caches, persist data, or close files.

The least intrusive implementation would be an interface a service implementer would opt into for receiving these events. Ex:
```java
public interface ServiceLifecycle {
// Called when Server.start() is called
void onStart(...);

// Called when Server.shutdown() or Server.shutdownNow() is called
void onShutdown(boolean hard, ...);
}
```

My initial thought is that `onStart()` would block `Server.start()`, so that the server wouldn't be ready until all services had successfully started. `onShutdown()` is trickier. It needs to be called only after the server has drained all requests.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.