Skip to content

Improve performance by reusing the gRPC connection #4

Closed
@philippgille

Description

Currently a new gRPC connection to lnd is created for every request.

It should be possible to create the gRPC connection only once when one of the middlewares is created, for example when NewHandlerFuncMiddleware(...) is called, but before the handler func is returned.

func createHandlerFunc(invoiceOptions InvoiceOptions, lndOptions LNDoptions, storageClient StorageClient, next http.HandlerFunc) func(w http.ResponseWriter, r *http.Request) {
	// <---- create the gRPC connection here and reuse it within the below func
	return func(w http.ResponseWriter, r *http.Request) {

Care must be taken regarding connections that are aborted/lost/..., for example due to a network error. Is it possible to reconnect with the existing connection object/ref?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions