Skip to content
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

add rdbms support for cdn metadata storage #151

Merged
merged 12 commits into from
Jun 6, 2018
Merged

Conversation

marpio
Copy link
Member

@marpio marpio commented Jun 4, 2018

Implements rdbms support and Mongo Saver for #147

)

// CdnMetadataEntry stores the module name and cdn URL.
type CdnMetadataEntry struct {
Copy link
Member

Choose a reason for hiding this comment

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

please, extract this into cdn/metadata and use in both mongo and rdbms

Copy link
Member

@michalpristas michalpristas Jun 5, 2018

Choose a reason for hiding this comment

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

will you update mongo in this pack as well? to use CdnMetadataEntry

if err := query.First(&result); err != nil {
return "", err
}
return result.RedirectURL, nil
Copy link
Member

Choose a reason for hiding this comment

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

possible to return result.RedirectURL, err? it should not be nil right

Copy link
Member Author

@marpio marpio Jun 4, 2018

Choose a reason for hiding this comment

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

Do you mean checkin if result == nil? If there is no row matching then First returns an error. Or did you mean something else?

Copy link
Member

@michalpristas michalpristas Jun 4, 2018

Choose a reason for hiding this comment

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

i meant replacing it with single return saying

err := query.First(&result)
return result.RedirectURL, err

result should not be nil so result.redirect uri should at least be empty string


// String is not required by pop and may be deleted
func (e CdnMetadataEntry) String() string {
je, _ := json.Marshal(e)
Copy link
Member

Choose a reason for hiding this comment

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

m: maybe just log the error? it does not feel right to ignore

Copy link
Member Author

Choose a reason for hiding this comment

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

It's the model code auto-generated by pop. Should I log this in the storage pkg as well?

Copy link
Member

@michalpristas michalpristas Jun 4, 2018

Choose a reason for hiding this comment

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

guess not, i did not realised that it is autogenerated

@michalpristas
Copy link
Member

thanks @marpio , it looks good to me, you addressed all things I had in mind very promptly. I will not complete it just yet and let @arschles review the pack as well

Copy link
Member

@arschles arschles left a comment

Choose a reason for hiding this comment

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

@marpio this looks awesome. I left a few nit-picks, can you fix them and @ me when it's done? I'll merge then

)

// CdnMetadataEntry stores the module name and cdn URL.
type CdnMetadataEntry struct {
Copy link
Member

Choose a reason for hiding this comment

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

@marpio can you name this CDNMetadataEntry?

// NewMongoStorage returns an unconnected Mongo backed storage
// that satisfies the Storage interface. You must call
// Connect() on the returned store before using it.
func NewMongoStorage(url, dbName string) *MetadataStore {
Copy link
Member

Choose a reason for hiding this comment

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

nit: this name "stutters" because it will be called with mongo.NewMongoStorage. can you call it NewStorage instead?

}
m.session = s

// TODO: collection as env var, or param to New()? together with user/mongo
Copy link
Member

Choose a reason for hiding this comment

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

I think this is ok as a constant for now. we can make it an env var if we need to, later on

// that satisfies the Getter and Setter interfaces. You must call
// Connect() on the returned store before using it.
// connectionName
func NewRDBMSStorage(connectionName string) *MetadataStore {
Copy link
Member

Choose a reason for hiding this comment

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

This name also "stutters" because it will be called with rdbms.NewRDBMSStorage - can you change this name to NewStorage instead?

Copy link
Member

@arschles arschles left a comment

Choose a reason for hiding this comment

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

@marpio looks great. thanks for this and sorry for the delay.

@arschles arschles merged commit 977d816 into gomods:master Jun 6, 2018
@marpio marpio deleted the cdn_rdbms branch June 7, 2018 12:17
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.

3 participants