-
Notifications
You must be signed in to change notification settings - Fork 101
Description
Currently, the http.New(ctx context.Context, params ...Parameter) (client.Service, error) constructor attempts to establish a connection to the beacon node and returns an error if the node is not reachable or not ready at the time of creation. This behavior makes it difficult to use the client in applications that want to proceed with initialization even if the beacon node is temporarily unavailable, and only handle connection errors at runtime when making actual API calls.
Feature request:
Please consider adding an option (e.g., AllowDelayedStart or similar) to allow http.New to always succeed, even if the beacon node is not reachable at creation time.
The client should internally handle connection state and return errors from API methods if the node is not available, rather than failing at construction.
This would enable applications to initialize all dependencies up front, and handle connection issues gracefully at runtime, improving resilience and flexibility.
Example use case
svc, err := http.New(ctx, http.WithAddress(endpoint), http.WithAllowDelayedStart(true))
if err != nil {
// Only fail for truly invalid parameters, not for connection state.
log.Fatalf("Failed to create client: %v", err)
}
// ... later, handle connection errors from svc methods as needed.