Skip to content

NioLoop to share Selector (typical use case is HTTP selector) #18

Open
@sagenschneider

Description

Rather than trying to code in the threading models and Selectors for a DataSource and it's Connections, allow them to be configured externally.

A primary use case for this is sharing the HTTP Selector. By allowing the NIO loop to be provided to the DataSource for it's connections it allows the HTTP Selector and threads to be used to service the communication with the database. This will allow a single thread to service HTTP requests, which is my understanding of the aim of NIO.

This is further work on #12 .

Example code (not yet working) available to demonstrate the concept:

https://github.com/sagenschneider/pgsql2/blob/281b7fcecd8c54a8041680d654ea9de9404427ff/src/main/java/org/postgresql/sql2/PGDataSource.java#L45 (shows how the NioLoop can be provided to the DataSource with a reasonable default)

https://github.com/sagenschneider/pgsql2/blob/281b7fcecd8c54a8041680d654ea9de9404427ff/src/main/java/org/postgresql/sql2/execution/NioLoop.java#L1 (NioLoop that may be implemented by the web server to share it's HTTP Selector with the DataSource)

https://github.com/sagenschneider/pgsql2/blob/281b7fcecd8c54a8041680d654ea9de9404427ff/src/main/java/org/postgresql/sql2/communication/ProtocolV3.java#L65 (using NioLoop for communication to database)

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions