everFinance / goar

Arweave http client and wallet implemented in go, Arweave SDK
Apache License 2.0
140 stars 44 forks source link

Support context.Context #56

Open benny-conn opened 1 year ago

benny-conn commented 1 year ago

I wish I could use this library but because it does not support go's context.Context I can't reliably use it. This library obviously performs operations over a network and it is common practice to use a context so that network operations can be cancelled by the context, either by manual cancellation or deadline. The go http package supports contexts with functions like http.NewRequestWithContext.

Even if I use contexts and goroutines to disregard the response of a *goar.Client when a context times out for example, there is no way to stop the execution of a function. If I were to be downloading content from arweave, it would continue downloading despite the context cancelling, and the program continuing running.

The only workaround I can see is manually setting a timeout on the http client, but this is bad practice and not predictable.

zyjblockchain commented 5 months ago

Hello yes, we support ctx on post data on arweave, but not support download data from arweave. it is so easy if support this, if you have enough time, and you can try to implement it and submit a pr. I would be very grateful.