#grpc

/

      • ejona
        pixelate: :)
      • cagedwisdom
        any chance I could hit you up to write me a little gist of how to write an auth interceptor? Im struggling with the context / executor / attach / detatch abstractions
      • ejona
        Oh, cagedwisdom you're back.
      • I can tell you how to use Context, too.
      • cagedwisdom
        that would be great
      • pixelate
        yeah ... it's funny -- you just get into "flow" of doing something -- at any given time our system is probably interacting with 15+ external APIs -- all of which I'd categorize as some kind of REST version... not all of them have proper clients, so for one-offs I usually just do the req, err := http.NewRequest(); cl := &http.Client{}; cl.Do(req) or whatever
      • ejona
        So Context is (most) immutable. So withValue returns a new instance.
      • cagedwisdom: Have you tried to use Contexts.interceptCall?
      • cagedwisdom
        yes, I know that part of my code is right, but not sure about the other parts.
      • ejona
        So Contexts.interceptCall should remove most dealing with attach/detach.
      • You're having trouble with passing work onto another executor and having Context follow?
      • cagedwisdom
        ejona, I think so. This is what I am working from at the moment: http://pastie.org/10968723
      • ejona
        cagedwisdom: Don't attach() on line 25.
      • Every attach() should have a cooresponding detach() within the same function (the current Context should be "scoped" like local variables)
      • In the case of Contexts.interceptCall, it automatically attaches so that the application and interceptors see a consistent Context.
      • cagedwisdom
        ejona, in my GreeterImpl this is what I have, and it's reporting -3 or null if I don't wrap it. http://pastie.org/10968726
      • ejona
        Hmm... wrap() doesn't execute the Runnable (it returns a new one). Are you passing the returned runnable somewhere else?
      • (Like another thread)
      • cagedwisdom
        no, I guess that's another mistake
      • ejona
        Oh, that could be why it's returning -3 :)
      • There is Context.run() which executes the runnable immediately.
      • But that's unnecessary in the code snippet, because the current context is... already the current one
      • Oh, I might see the problem.
      • The Context.Key uses reference equality.
      • The String passed to it is just for debugging.
      • So you need to use the same Key instance in the handler as the AuthInterceptor (like AuthInterceptor.contextKey)
      • cagedwisdom
        ahhh
      • okay gonna try that :)
      • pixelate
        cagedwisdom: btw is it a Arrested Development reference?
      • cagedwisdom
        pixelate, good memory. :) Caged wisdom was the name of the spiritual life coaching videos George Sr. sold from his stay in prison.
      • ejona, thanks, that fixed my issue. tyvm.
      • ejona
        Glad it's working!
      • cagedwisdom
        Me too.
      • pixelate
        anonymous types + interfaces in go are such a powerful too
      • tolo
      • tool
      • lol
      • jxv has left the channel
      • cagedwisdom has quit
      • cagedwisdom joined the channel
      • cagedwisdom has quit
      • cagedwisdom joined the channel
      • cagedwisdom has quit
      • cagedwisdom joined the channel
      • cagedwisdom has quit
      • cagedwisdom joined the channel
      • cagedwisdom has quit
      • cagedwisdom joined the channel
      • cagedwisdom has quit
      • cagedwisdom joined the channel
      • cagedwisdom has quit
      • cagedwisdom joined the channel
      • cagedwisdom has quit
      • cagedwisdom joined the channel
      • cagedwisdom has quit
      • cagedwisdom joined the channel
      • cagedwisdom has quit
      • aaa_ joined the channel
      • aaa_ has quit
      • dgryski joined the channel
      • hatmaker joined the channel
      • hatmaker has quit
      • hatmaker joined the channel
      • hatmaker has quit
      • hatmaker joined the channel
      • hatmaker has quit
      • hatmaker joined the channel
      • hatmaker has quit
      • hatmaker joined the channel
      • hatmaker has quit
      • hatmaker joined the channel
      • hatmaker has quit
      • dgryski has quit