Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Represent Global IDs as URIs: globalid://basecamp/Todo/1234 #16

Closed
wants to merge 1 commit into from

Conversation

jeremy
Copy link
Member

@jeremy jeremy commented Aug 1, 2014

  • Share Global IDs among collaborating apps and with non-Ruby/Rails code
  • Well-known format with parsers & generators already implemented
  • Pave the way to put verifier signature in the URI params, or e.g. a "?version=456" optimistic lock

Next steps:

  • Beef up the URI parser
  • Integrate signing into the URI
  • Introduce a url-safe base64 #to_param

@jeremy jeremy changed the title Represent as a URI: globalid://app/Class::Name/1234 Represent Global IDs as URIs: globalid://basecamp/Todo/1234 Aug 1, 2014
end

attr_reader :uri, :app, :model_name, :model_id
Copy link
Member

Choose a reason for hiding this comment

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

Should we add tests to make sure we are assigning the right URL parts to these instance variables?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. If we're positive on the direction (using URIs) I'll include a real parser as well 😁

@jeremy
Copy link
Member Author

jeremy commented Aug 2, 2014

(An alternative is to use URNs, but they're wordier and don't have broad generation/parsing support like URIs.)

@cristianbica
Copy link
Member

@dhh @rafaelfranca what do we do with this? Dhh said to merge globalid into rails in the activejob PR (seuros/actionmailer-deliver_later#6 (comment)) but if we're going to migrate the representation to URIs we should do it ASAP.
I personally like the URI idea :)

@seuros
Copy link
Member

seuros commented Aug 12, 2014

I like the uri idea aswell. We just have to add that to the changelog since it a breaking change.

@dhh
Copy link
Member

dhh commented Aug 12, 2014

Cristian, I’m game for @jeremy’s URI idea. So I say we polish that up as part of this. But @jeremykemper also suggested that we split this out in a separate gem entirely, so Sinatra and others can use it too. I like that idea. So basically just go with a separate “globalid” gem, and then have activejob rely on that.

On Aug 12, 2014, at 12:23, Cristian Bica notifications@github.com wrote:

@dhh @rafaelfranca what do we do with this? Dhh said to merge globalid into rails in the activejob PR (seuros/actionmailer-deliver_later#6 (comment)) but if we're going to migrate the representation to URIs we should do it ASAP.
I personally like the URI idea :)


Reply to this email directly or view it on GitHub.

@seuros
Copy link
Member

seuros commented Aug 12, 2014

I though about the separate gem, but Globalid depend on activemodel. If we embed it , then sinatra app will have just to require activemodel 4.2+

@dhh
Copy link
Member

dhh commented Aug 12, 2014

What does GlobalID need from activemodel? Could we disconnect it?

On Aug 12, 2014, at 12:30, Abdelkader Boudih notifications@github.com wrote:

I though about the separate gem, but Globalid depend on activemodel. If we embed it , then sinatra app will have just to require activemodel 4.2+


Reply to this email directly or view it on GitHub.

@seuros
Copy link
Member

seuros commented Aug 12, 2014

.id

@dhh
Copy link
Member

dhh commented Aug 12, 2014

We can just have a protocol, imo. That requires that anything that mixes in GlobalID has to provide these things.

@seuros
Copy link
Member

seuros commented Aug 12, 2014

I had implemented something in #10 but it was rejected.

@cristianbica
Copy link
Member

GlobalID needs .id on the instance and .find on the class. If we are going to make the GlobalID backend agnostic then GlobalID will be a mixin. We could go the acts_as_* way and have something like:

class ActiveRecord::Base
  global_identificable by: :id, finder: :find
end

and with the URI stuff it looks pretty good to me

@dhh
Copy link
Member

dhh commented Aug 12, 2014

I don’t even think we need to make those configurable at this point. We’re just putting out the contract that to use GlobalID, you have to have an #id and a #find method.

Then we’ll include GlobalID directly into ActiveModel in the activemodel gem.

On Aug 12, 2014, at 13:51, Cristian Bica notifications@github.com wrote:

GlobalID needs .id on the instance and .find on the class. If we are going to make the GlobalID backend agnostic then GlobalID will be a mixin. We could go the acts_as_* way and have something like:

class ActiveRecord::Base

global_identificable by: :id, finder: :find
end
and with the URI stuff it looks pretty good to me


Reply to this email directly or view it on GitHub.

@seuros
Copy link
Member

seuros commented Aug 12, 2014

@jeremy can you rebase and merge this PR ?

@jeremy
Copy link
Member Author

jeremy commented Aug 12, 2014

@seuros Yep. I have a few more points to complete before merge.

@cristianbica
Copy link
Member

Actually you're right. When we'll find someone who wants GlobalID and uses id/find for something else we will implement

@jeremy
Copy link
Member Author

jeremy commented Aug 13, 2014

Moved to #17 based on the uri branch in this org instead of mine.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants