Skip to content
This repository has been archived by the owner on Apr 22, 2022. It is now read-only.

How do you suppose to write an SQL implementation of db.go ? #23

Closed
tssajo opened this issue Jul 20, 2016 · 4 comments
Closed

How do you suppose to write an SQL implementation of db.go ? #23

tssajo opened this issue Jul 20, 2016 · 4 comments

Comments

@tssajo
Copy link
Contributor

tssajo commented Jul 20, 2016

I did write one and all interface functions worked perfectly, these:

    GetAppByAppID(appID string) (*app, error)
    GetAppByKey(key string) (*app, error)
    AddApp(*app) error

However, the following from the app struct should be kept in memory for all apps at all times IMO:

    Channels    map[string]*channel
    Connections map[string]*connection

    Stats *expvar.Map

You don't really think these should be serialized and saved to the database as well? (and when to save these? when anything inside these changes???)

IMO, only these should be stored in the database from the app struct::

    Name                string
    AppID               string
    Key                 string
    Secret              string
    OnlySSL             bool
    ApplicationDisabled bool
    UserEvents          bool
    WebHooks            bool
    URLWebHook          string

and when these get updated in the database then we should re-read these (maybe check for db changes periodically from a go routine) and update the in-memory database with the new values. When we do this updating, we should never touch the app's Channels, Connections and Stats in memory, I think.

What is your opinion on this? How do you suppose to store the AppIDs and the other app data in an SQL database with the current Ipe code base? IMO, some restructuring might be needed for this.

@dimiro1
Copy link
Owner

dimiro1 commented Jul 21, 2016

I am in a vacation. I will answer your questions when I arrive. Thank you.

@tssajo
Copy link
Contributor Author

tssajo commented Jul 23, 2016

@dimiro1 Take your time and have a nice vacation!
I already modified Ipê for myself to store and keep updating a lot more data (e.g. metrics which you currently store via expvar) in a MySQL database. I really like the code base, so I might become a frequent contributor to your project.

@dimiro1
Copy link
Owner

dimiro1 commented Aug 7, 2016

However, the following from the app struct should be kept in memory for all apps at all times IMO:

Yes it is something that need to get better.

You don't really think these should be serialized and saved to the database as well? (and when to save these? when anything inside these changes???)

The initial idea was to save references in database or use a Redis PubSub

IMO, only these should be stored in the database from the app struct::

I agree with you

What is your opinion on this? How do you suppose to store the AppIDs and the other app data in an SQL database with the current Ipe code base? IMO, some restructuring might be needed for this.

Could be a SQL database to store apps and a Redis Server to store connections and handle the pubsub stuff.

I really like the code base, so I might become a frequent contributor to your project.

Cool, feel free to hack in this project, I am not using in production anymore. You can send patches if we are aligned i can give you write permissions in this repo.

@tssajo
Copy link
Contributor Author

tssajo commented Aug 10, 2016

@dimiro1 , thanks for your answers.

I will keep sending you just a few PR's. I do not think that I need to have write permission to this repo as of yet. But thanks for offering.

I close this thread now.

@tssajo tssajo closed this as completed Aug 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants