Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
392a5ff to
bef20bd
Compare
|
I have read the CLA document and I hereby sign the CLA |
7e16396 to
2f2c004
Compare
| # If `certificateHost` is not provided, then the certificate is checked against `address`. | ||
| } | ||
|
|
||
| tcp :group { |
There was a problem hiding this comment.
Please add doc comments.
I assume this is something like:
Connect to the server over raw TCP. Bindings to this service will only support the
connect()method;fetch()will throw an exception.
| kj::HttpHeaderTable& headerTable, | ||
| kj::Timer& timer, kj::EntropySource& entropySource) | ||
| : addr(kj::mv(addrParam)), | ||
| inner(kj::newHttpClient(timer, headerTable, *addr, { |
There was a problem hiding this comment.
Isn't the point of this class that it should form raw TCP connections, not HTTP? I'd expect request() throws an exception, and connect() calls addr->connect() without using an HttpClient.
| kj::String user, kj::String password) | ||
| : clientIndex(clientIndex), database(kj::mv(database)), | ||
| user(kj::mv(user)), password(kj::mv(password)) { | ||
| randomHost = randomUUID(kj::none); |
There was a problem hiding this comment.
Does this actually need to be random? Could it instead just be a static fake string value?
There was a problem hiding this comment.
Wouldn't that cause issues if there were 2+ Hyperdrive bindings?
There was a problem hiding this comment.
Oh sorry, I missed that this is being used with setConnectOverride(). In that case, can we please generate the hostname the same way we do in the internal codebase? Matching behavior as much as possible is helpful for testing purposes.
randomHost = kj::str(kj::encodeHex(randomBytes), ".hyperdrive.local");
There was a problem hiding this comment.
I didn't see a random byte generation function so I went with the UUID, should I port one over or use the UUID with the .hyperdrive.local appended?
There was a problem hiding this comment.
I think we should match the formatting. UUIDs have a specific format which is not the same as a hex string.
Take a look at how randomUUID() itself generates random bytes -- it calls OpenSSL's RAND_bytes(). You can do the same here.
There was a problem hiding this comment.
Ah alright. Should be good now
7b8c0f5 to
085c92e
Compare
|
Marking this with |
ed3f25a to
51a610d
Compare
e6184a0 to
9173986
Compare
It passed internally, so I think the tag's set to be removed (I can't remove it though) |
9173986 to
c7c8da4
Compare
2ecdb57 to
83e2a95
Compare
60d23cd to
d1e4b68
Compare
a-robinson
left a comment
There was a problem hiding this comment.
Looks good, just a couple minor things left. Thanks for confirming that it is actually able to successfully establish connections. Did you test what happens when trying to connect to an address that isn't listening?
| @@ -0,0 +1,106 @@ | |||
| #include "hyperdrive.h" | |||
There was a problem hiding this comment.
Looks like we still need to add a copyright header here
| try { | ||
| auto errorBody = co_await e->readAllText(); | ||
| kj::throwFatalException(KJ_EXCEPTION( | ||
| FAILED, kj::str("unexpected error connecting to SQC from process sandbox: ", errorBody))); |
There was a problem hiding this comment.
Not quite -- we aren't connecting from a "process sandbox" here. I'd just remove the "from process sandbox" part of these log messages
| JSG_LAZY_READONLY_INSTANCE_PROPERTY(database, getDatabase); | ||
| JSG_LAZY_READONLY_INSTANCE_PROPERTY(user, getUser); | ||
| JSG_LAZY_READONLY_INSTANCE_PROPERTY(password, getPassword); | ||
| JSG_LAZY_READONLY_INSTANCE_PROPERTY(scheme, getScheme); |
There was a problem hiding this comment.
We don't want to be in the business of supporting more public fields/methods in workerd than in the production workers runtime. We should avoid exposing this for now.
| f.fulfill(kj::none); | ||
| return kj::mv(stream); | ||
| }, [&f = *paf.fulfiller](kj::Exception e) { | ||
| KJ_LOG(WARNING, "failed to connect to local hyperdrive process", e); |
There was a problem hiding this comment.
Was it intentional that this was left as is?
| kj::String password; | ||
| kj::String scheme; | ||
| bool registeredConnectOverride = false; | ||
| kj::Promise<kj::Own<kj::AsyncIoStream>> connectToDb(); |
There was a problem hiding this comment.
Style nit, but it'd be nice to put an empty line in between the class's member variables and any private functions just to more cleanly visually separate them. When scanning over this I initially was trying to figure out why we needed a connectToDb variable before I stopped to take a closer look.
| auto connectReq = kj::newHttpClient(*service)->connect( | ||
| kj::str(getHost(), ":", getPort()), headers, kj::HttpConnectSettings{}); | ||
|
|
||
| // auto conectionRequest = |
fb15483 to
1d1206f
Compare
1d1206f to
50c27e6
Compare
|
Just to be clear, I'll merge this as soon as the tests are green, but given that your branch is on your fork rather than the main repo, the builds are likely to take a few hours. |
|
@a-robinson alright, sounds good. Thanks! |
|
Aaaand I forgot to squash the commits down :( I'm sorry for making the history messier, anyone who's reading this. |
Support is already in progress (see cloudflare/workerd#1266) and should be coming in the next few weeks, but we've already had at least one user get very confused by this and cause us to spend time on debugging before realizing the problem was that they were talking about problems in wrangler dev rather than at the edge. This is an easy way to attempt to mitigate that for now.
Support is already in progress (see cloudflare/workerd#1266) and should be coming in the next few weeks, but we've already had at least one user get very confused by this and cause us to spend time on debugging before realizing the problem was that they were talking about problems in wrangler dev rather than at the edge. This is an easy way to attempt to mitigate that for now.
…g does not work Description Hyperdrive is supported locally (see cloudflare/workerd#1266) and this warning is not longer accurate. It was added while the support was in progress to avoid confusion (cloudflare@54800f6), but now that local support for Hyperdrive bindings has been added, this log is incorrect and should be removed
…g does not work (#5812) * Remove Hyperdrive warning log indicating that Hyperdrive local binding does not work Description Hyperdrive is supported locally (see cloudflare/workerd#1266) and this warning is not longer accurate. It was added while the support was in progress to avoid confusion (54800f6), but now that local support for Hyperdrive bindings has been added, this log is incorrect and should be removed * Add changeset * Update .changeset/thirty-kings-serve.md Co-authored-by: Matt <granjef3@gmail.com> * Nit changeset fix --------- Co-authored-by: Matt <granjef3@gmail.com>
| kj::String Hyperdrive::getConnectionString() { | ||
| return kj::str(getScheme(), "://", getUser(), ":", getPassword(), "@", getHost(), ":", getPort(), | ||
| "/", getDatabase(), "?sslmode=disable"); | ||
| } |
There was a problem hiding this comment.
@tmthecoder @a-robinson this hardcodes sslmode=disable. This prevents connection to remote databases such as Azure, Neon, etc. when developing locally. Can we have a way to connect to these databases which needs sslmode=require, while retaining the ability to connect to local Postgres with does need sslmode=disable?
There was a problem hiding this comment.
Can we have a way to connect to these databases which needs sslmode=require, while retaining the ability to connect to local Postgres with does need sslmode=disable?
If you want to support remote databases that require SSL but also local DBs that don't support it, it sounds like what we want for local mode is sslmode=prefer, which allows SSL but doesn't require it.
It should be possible to vary the default sslmode in workerd compared to on the edge, but I'd suggest bringing it up internally either in chat or as a ticket so we don't lose track of it.
And I wouldn't expect Tejas to respond given that his internship ended last year :)
Adda a new binding type
Hyperdriveas well as a corresponding Service definitionExternalTcpServicethat allows TCP connections to the designated host address & port