-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Refactor/http gateway #1191
Refactor/http gateway #1191
Conversation
@@ -344,39 +344,21 @@ Data should be in the format specified by the --inputenc flag. | |||
} | |||
|
|||
// objectData takes a key string and writes out the raw bytes of that node (if there is one) | |||
func objectData(n *core.IpfsNode, fpath path.Path) (io.Reader, error) { | |||
dagnode, err := core.Resolve(n, fpath) | |||
func objectData(n *dag.Node, err error) (io.Reader, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's so little left in this function after you remove the Resolve
call that I'd just drop this (and objectLinks
, etc.) entirely. Unless we really want to keep them around for the debug logging…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think its probably worth dropping, it provides no tangible value added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought so too, this is mixed up from PR#1189 though. I'll remove it there and rebase this once it is merged.
On Sat, May 02, 2015 at 08:07:34PM -0700, Henry wrote:
So I've been thinking about this a bit, and I can't wrap my head On the other hand, I barely speak Go, so feel free to ignore my |
@@ -162,7 +116,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |||
errmsg = errmsg + "bad request for " + r.URL.Path | |||
} | |||
w.Write([]byte(errmsg)) | |||
log.Debug(errmsg) | |||
log.Error(errmsg) // TODO(cryptix): Why are we ignoring handler errors? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should never ignore errors. any time an error is ignored anywhere in our code, its a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any time an error is ignored anywhere in our code, its a bug.
very much agreed.
though:
- logging is not always an ignored error. sometimes there is nothing to do in a messy io environment (e.g. receiving incoming connections from things that are not running the ipfs protocol. there is nothing to do but log/bookkeep).
- this error isn't ignored. an HTTP error header is written, and the error itself is written out to the user for feedback. we could do something else for bookkeeping (like add it to a counter somewhere, throw an event, etc), but correctness is ok here.
@wking contexts should be used when you are going to either perform RPC's, spawn off child goroutines you want to handle, or in general when you want to be able to cancel an operation. Not everything needs to take them, but our high level things should take them, otherwise things may hang. Contexts also allow us to more easily clean up after ourselves; cancelling a context says to all your children "stop whatever you are doing, clean up, and exit ASAP" |
On Sat, May 02, 2015 at 08:51:09PM -0700, Jeromy Johnson wrote:
Lots of things can block besides RPCs and goroutines. Why doesn't
Which you can do between processes with signals, or in an event-loop |
Ill let google explain it better than I can, lol https://blog.golang.org/context |
ce4f890
to
2a74b6a
Compare
@wking on the contexts-- the reality with |
return node, p, err | ||
} | ||
|
||
// TODO(cryptix): these four helper funcs shoudl also be available elsewhere, i think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed.
2a74b6a
to
9b60a42
Compare
TODO:
|
416f435
to
34ac0c2
Compare
} | ||
|
||
if r.Method == "HEAD" { | ||
if r.Method == "GET" || r.Method == "HEAD" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not case "GET", "HEAD":
in the switch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the above only is for Writeable
. I didn't want to introduce another switch with just one case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhh missed that-- my mistake :)
230e4c7
to
1a7b85b
Compare
rebased |
@jbenet Yea, that one was stupid.. i'll squash related once when I'm done. |
1a7b85b
to
f867531
Compare
#1219 merged the changed without the put/writable tests parts. Rebased on top of new master. |
0823965
to
4537311
Compare
Refactor/http gateway This commit was moved from ipfs/kubo@08ea56c
This is supposed to fix #1150 and clean up the gateway http handler in general. Based on #1189.
This is currently WIP but I need some feedback first, see my
TODO
comments in the code.