Skip to content

JSON in types #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2018
Merged

Conversation

clhodapp
Copy link
Contributor

@clhodapp clhodapp commented Dec 2, 2016

Adds a mapping for json to default type mappings and makes them public. Right now, I've had to duplicate the whole thing into my code, add json to it, and use withCustomTypes. Why not let finagle-postgres query the database for the types at startup? Well.. right now there's a bug such that failures to pull the type-map at startup get memoized in a Future, causing your client to be dead forever (which I intend to fix in a subsequent pull request).

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 77.711% when pulling bc03998 on clhodapp:feature/json-in-types into dee2332 on finagle:master.

@clhodapp clhodapp changed the title Feature/json in types JSON in types Dec 3, 2016
@clhodapp clhodapp force-pushed the feature/json-in-types branch 2 times, most recently from 5c3a0ad to de29d19 Compare January 19, 2017 04:13
@clhodapp
Copy link
Contributor Author

Gah: travis-ci/travis-ci#4264

@clhodapp clhodapp force-pushed the feature/json-in-types branch 3 times, most recently from 1b0d55f to 00e077d Compare January 19, 2017 08:18
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 77.711% when pulling 00e077d on clhodapp:feature/json-in-types into dee2332 on finagle:master.

@@ -69,7 +69,7 @@ object PostgresClient {

case class TypeSpecifier(receiveFunction: String, typeName: String, elemOid: Long = 0)

private[finagle] val defaultTypes = Map(
val defaultTypes = Map(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does it need to be public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm making it public to make things slightly easier for the next person who finds that one of the types they use isn't part of defaultTypes and who doesn't want to use the fatally-bugged dynamic-type-map-building feature. Right now, if you want to use withCustomTypes, chances are that you'll have to copy this definition of defaultTypes into your code so you can have a Map that adds the mappings you need to pass to withCustomTypes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(I say it's "fatally-bugged" because the Future here caches any failure to pull the typeMap at startup forever, thus borking the client)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reading these comments again, I think my tone may be slightly abrasive. Sorry about that!

@@ -83,6 +83,7 @@ object PostgresClient {
Types.TID -> TypeSpecifier("tidrecv", "tid"),
Types.XID -> TypeSpecifier("xidrecv", "xid"),
Types.CID -> TypeSpecifier("cidrecv", "cid"),
Types.JSON -> TypeSpecifier("json_recv", "json"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

In general I've tried to only include types in the default map that are baked-in to postgres without installing an extension. I think that's now the case for json so this should be OK. Can you confirm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

JSON was added as a baked-in feature in Postgres 9.2 (released in 2012, so it's pretty likely that most people are on at least that version at this point).

@clhodapp clhodapp force-pushed the feature/json-in-types branch from 00e077d to 4ac382f Compare May 3, 2017 23:34
@clhodapp
Copy link
Contributor Author

clhodapp commented May 3, 2017

(Rebased to fix merge conflict)

@clhodapp clhodapp force-pushed the feature/json-in-types branch from 4ac382f to b28ecd9 Compare May 3, 2017 23:34
@clhodapp clhodapp force-pushed the feature/json-in-types branch 2 times, most recently from 9b1ed39 to bbd43d5 Compare July 17, 2017 02:01
@jeremyrsmith
Copy link
Collaborator

@clhodapp I'm sorry for the lack of attention. If you rebase this I'd give it a 👍 (though we should also add some retries to retrieveTypeMap, if the bug you mentioned still exists which I'm pretty sure it does)

@dangerousben
Copy link
Collaborator

(fixed conflicts and this now builds but it needs a rebase and I don't know how to do that to somebody else's PR)

@clhodapp clhodapp force-pushed the feature/json-in-types branch from 1080a2b to 4e23133 Compare May 17, 2018 20:00
@clhodapp
Copy link
Contributor Author

Finally rebased this. Sorry for the delay. It looks like some other JSON(B)-related work already made its way onto master. I think that this is still needed, though.

@dangerousben dangerousben self-requested a review May 26, 2018 07:13
@dangerousben dangerousben merged commit 3d4ab10 into finagle:master May 26, 2018
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.

4 participants