Skip to content

Generic Interceptor/Middleware for caching, retry, circuit breaker, etc. #3261

Open
@StevenACoffman

Description

@StevenACoffman

What do you want to change?

See prior #1442 #930 #1076 #2207

ngrok/sqlmw provides database/sql interface interceptors (middleware), but does not work with the pgx / pgxpool interface. In addition, sqlc likes to remove comments that are middleware directives without providing a configuration option to change this behavior (comment passthrough).

My specific use case is that I would like a sqlc plugin like prashanthpai/sqlcache which provides a nice declarative mechanism for caching individual queries to Redis to improve performance. Other use cases like circuit breakers, retry mechanisms, etc. are also facilitated by having generic interceptor middleware in sqlc.

Describe the solution you'd like
A plugin or package like ngrok/sqlmw specific to sqlc but usable for pgx / pgxpool to facilitate a generic caching layer like prashanthpai/sqlcache without resorting to the database/sql interface.

BTW, prashanthpai/sqlcache relies on query "annotations", like so:

-- name: GetUsers :many
-- @cache-ttl 30
-- @cache-max-rows 10
SELECT * FROM users;

What database engines need to be changed?

PostgreSQL

What programming language backends need to be changed?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions