Open asutula opened 5 years ago
@sanderpick would love your thoughts on this today if possible.
That "complicated concurrency management" would be something like:
refreshSession
(and possibly registerCafeWithId:completion:
)Nice, I like it!
Hey @sanderpick, started work on this an immediately hit a blocker... When a file sync http request fails, I need to refresh the session for the corresponding cafe, but our api to refresh a session takes a peer id. The sdk requests handler class knows nothing about peer id, just http requests and cafe urls. Do we need to add a refreshCafeForUrl
method (which will let me refresh the session directly by URL) or maybe cafeForRequestId
(which would let me look up the peer id for the failed http request)?
For a minute I thought maybe we could add peerId
to CafeHTTPRequest
(the thing that gets passed into the callback after writing a request to disk), but that's not ideal because the sdk would have to keep a list of all currently processing CafeHTTPRequest
s and it would need to be persistent across app launches. Possible, but a big chunk of work for ios and android considering this persistent state already exists in the go-textile layer.
cafeForRequestId
is seeming like the best option to me so far.
Took a stab at this here https://github.com/textileio/go-textile/pull/850
There is currently no handling of an expired client cafe session. This will cause file sync requests to fail and that's the end of the story. I'm imagining we should do something like:
TextileDelegate
protocol that is something likeregisterCafeWithId:completion:
. This will get called in a situation described further down this list.registerCafeWithId:completion:
. The host app will register the cafe and then call thecompletion
handler passed to it which will un-mark the cafe sync request as pending.Little tricky, but that sounds like a decent solution. Devil is probably in the details. Input appreciated.
Hmm one detail... If there are simultaneous http uploads happening, they could all fail and without some complicated concurrency management, the session would be refreshed multiple times.