Skip to content

server: Add a ContextFactory parameter to the handler, giving integrators control over the *sql.Context creation.#2859

Merged
reltuk merged 2 commits intomainfrom
aaron/handler-ctxfactory
Feb 26, 2025
Merged

server: Add a ContextFactory parameter to the handler, giving integrators control over the *sql.Context creation.#2859
reltuk merged 2 commits intomainfrom
aaron/handler-ctxfactory

Conversation

@reltuk
Copy link
Copy Markdown
Contributor

@reltuk reltuk commented Feb 26, 2025

No description provided.

Copy link
Copy Markdown
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}
//handler = NewHandler_(e, sm, cfg.ConnReadTimeout, cfg.DisableClientMultiStatements, cfg.MaxLoggedQueryLen, cfg.EncodeLoggedQuery, listener)
return newServerFromHandler(cfg, e, sm, handler, listener)
func NewServer(cfg Config, e *sqle.Engine, ctxFactory sql.ContextFactory, sb SessionBuilder, listener ServerEventListener) (*Server, error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love having both a ctxFactory and a SessionBuilder here, the reality is these two responsibilities are closely related if not overlapping. Ideally this would be a single real interface with two methods that a single type could implement. This isn't a deal breaker but as long as you're monkeying around in here it might be worthwhile to see what it would take to get there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very much agree. This ContextFactory is a pretty weird integration point as of now. There are other ways of achieving what we need. For example, we could allow an integrator to pass along a []sql.ContextOption instead, and make a new context option like WithContextTransform(func(context.Context) context.Context). The reality is that the lifecycle around all these things is really subtle right now, and making changes is somewhat fragile and far reaching.

This change as is is useful to me and I have doltgres and dolt fixes ready for it, so I'm going to go ahead and land it, but I may revisit it soon.

@reltuk reltuk merged commit 5b478d4 into main Feb 26, 2025
7 of 8 checks passed
@Hydrocharged Hydrocharged deleted the aaron/handler-ctxfactory branch December 17, 2025 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants