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

feat: adds profile and profiles query api endpoint #23

Merged
merged 5 commits into from
Dec 15, 2018

Conversation

zachferland
Copy link
Contributor

No description provided.

@zachferland zachferland force-pushed the feat/add-profile-query-endpoint branch 2 times, most recently from 6e910b0 to e649ee7 Compare December 11, 2018 01:06
Copy link
Member

@oed oed left a comment

Choose a reason for hiding this comment

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

Looks great overall. I see one minor tweak needed to the invalidation.

package.json Outdated Show resolved Hide resolved
@@ -80,6 +90,8 @@ async function pinningNode () {
openDB(odbAddress)
})
}

cache.invalidate(address)
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this is in the wrong place. I think it should be called when we replicate an entry in any db.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah could be moved, to be more exact, since we know when changes happen. Was just based on quick initial assumption that something MAY have change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually not going to change until next sprint tests/cleanup. To be more exact, helpful if differentiate between priv vs pub open. And need to fix #27 so that its not called over and over. Easy change after, and still valid at the moment, just a bit less effective.

@zachferland zachferland force-pushed the feat/add-profile-query-endpoint branch from e649ee7 to 4a3c294 Compare December 11, 2018 19:51
@zachferland
Copy link
Contributor Author

zachferland commented Dec 11, 2018

Only a few practical things/configs remain:

  • add reds instance on AWS and all the configs here
  • add port and other configs

@oed
Copy link
Member

oed commented Dec 12, 2018

Will it be possible to have multiple pinning-nodes that connect to the same reds instance on AWS when we split up the pinning network? Seems like that would be the best approach, then we can just have one serverless function for querying that db.

@zachferland
Copy link
Contributor Author

easy to connect multiple nodes to redis instance, maybe the caching strategy would change a bit, or be more aggressive if wanted to limit the number of cache misses. We could have a server less function as the api query endpoint, but the pinning nodes would have to be able to serve the same requests, since they would be the fallback for a cache miss

@oed
Copy link
Member

oed commented Dec 12, 2018

Oh, I see yeah good point. I guess the benefit of using a serverless function would only be there when we start having multiple pinning-nodes then. (the serverless function would check the redis cache first, then it would know which pinning-node to make a request to)

@zachferland
Copy link
Contributor Author

zachferland commented Dec 12, 2018

yeah exactly

I don't know exactly what you are thinking for splitting up the pinning nodes, but I'm starting to think the best approach would be to use a s3 datastore for ipfs, and the same for the orbitdb cache. Then all ec2 instances can share a single s3 instance, which scales easily, and removes a lot of dependencies around state (and complexity, backups, etc). Now with that node specific state being removed, connections don't have to be made to a particular node, they just have to be made to any node with pubsub/ipfs already running. They can still be distributed evenly by name/hash. Also without that state dependency it easier to scale these nodes up and down on demand.

Another plus of this, we could have a server less function for the api queries, where it ask redis, if no cache hit, it can then get the data directly from s3. We could have a function that directly maps the raw ipfs and orbit db data to the response (rather than through the orbitdb/ipfs interface)

@oed
Copy link
Member

oed commented Dec 14, 2018

@zachferland Let's schedule a call sometime next year to discuss this!

@zachferland zachferland changed the title [WIP] feat: v1, adds profile query api endpoint feat: adds profile and profiles query api endpoint Dec 14, 2018
@zachferland
Copy link
Contributor Author

@oed sounds good, Ill add a call sometime the first week

Also this all set, looks pretty similar to when you first reviewed though

@oed
Copy link
Member

oed commented Dec 14, 2018

Ty, I'll have another look now!

@zachferland zachferland force-pushed the feat/add-profile-query-endpoint branch 2 times, most recently from 3ed6319 to 9f12edc Compare December 14, 2018 17:54
Copy link
Member

@oed oed left a comment

Choose a reason for hiding this comment

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

Looks good, just some questions.

server.js Outdated

const profiles = await Promise.all(profilePromiseArray)
const parsed = profiles.reduce((acc, val) => {
acc[val['rootStoreAddress']] = val['profile']
Copy link
Member

Choose a reason for hiding this comment

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

hm, shouldn't the key be the eth-address rather than the rootStoreAddress?

Copy link
Member

Choose a reason for hiding this comment

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

Or how do you map eth-addr -> profile clientside?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup that should be eth address, let me make sure the names are clear as well, that was just recently change to use eth-addr instead of rootstoreaddress. The return obj is {ethaddress: addressprofileObj, ehtaddress2: ....., ....}

Copy link
Member

Choose a reason for hiding this comment

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

Is it really? looks like the profiles object is [{rootStoreAddress, profile}, ...], so the return obj would become {rootStoreAddress: profileObj, ...}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

meant to say request was changed from using root addresses to using eth address, but yes the response is currently incorrect as you described

await readyPromise

await Promise.resolve(resolve => {
rootStore.events.on('replicated', resolve)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we wait for this event? replicated is only emitted if you replicate from the network which we won't do here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok this I'm also wondering, pretty sure I originally removed it, things didn't work and then added it back in. And then saw no time lost in opening and fetching the profile. So not sure exactly what it is doing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I will take a closer look to pinpoint or add details for a future issue

Copy link
Member

Choose a reason for hiding this comment

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

that's odd. let's keep it then

Copy link
Member

Choose a reason for hiding this comment

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

ok, ty!

publicStore.load()
await readyPromisePublic
await Promise.resolve(resolve => {
publicStore.events.on('replicated', resolve)
Copy link
Member

Choose a reason for hiding this comment

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

Same Q as above, + indenting :)

@zachferland zachferland force-pushed the feat/add-profile-query-endpoint branch from 9f12edc to 3227ea8 Compare December 15, 2018 16:59
@zachferland zachferland force-pushed the feat/add-profile-query-endpoint branch from 3227ea8 to 8f3947c Compare December 15, 2018 17:16
@zachferland zachferland merged commit 176501d into master Dec 15, 2018
@c-castillo c-castillo deleted the feat/add-profile-query-endpoint branch January 15, 2019 14:27
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

2 participants