Git Product home page Git Product logo

Comments (11)

yurishkuro avatar yurishkuro commented on May 14, 2024 1

This may sound like a nuanced answer, but "when in Rome..." In other words, having a library that deviates from std lib conventions can hurt its chances of adoption. I am a big fan of passing the context explicitly, especially when designing business service APIs, because it encourages developers to pass it around and make use of it (e.g. respect cancellation signals). But given that std lib chose a different approach for http.Request, I would make an exception and stick with the std lib API. @yutongp's dual source of truth argument makes a lot of sense.

On a separate note, I thought Fx would be integrated with yarpc and this whole question would become a moot point, since people won't be writing http handlers explicitly, but rather yarpc handlers that do pass context as argument.

from fx.

yutongp avatar yutongp commented on May 14, 2024

BTW I do agree context should be the first param in all business logic layers passed HTTP layer. So the user define HTTP handler probably looks like:

func (h Handler) ServeHTTP(w ResponseWriter, r *Request) {
  ctx := r.Context() 
  businessReq := toBusinessModel(r)
  businessResp := handleBusiness(ctx , businessReq)
  ....
}

from fx.

yutongp avatar yutongp commented on May 14, 2024

I can put out a diff for this during weekend. It is more about what direction we would like to go. Any thought?

from fx.

ascandella avatar ascandella commented on May 14, 2024

We discussed this at length, and were encouraged by the observability team to make it an explicit parameter.

cc @anuptalwalkar @yurishkuro

from fx.

yutongp avatar yutongp commented on May 14, 2024

I feel like yarpc doesn't have all the features for a pure Go HTTP service (why pure HTTP service? that could be another discussion) for now. Just leak of supporting url-encoded data and user unable to set http response code is almost a No for a lot of use cases. So for now having a http package with all the tool chains we need make sense I think.

from fx.

glibsm avatar glibsm commented on May 14, 2024

@yutongp for yarpc http is just a protocol. We have a separate uhttp module, which has nothing to do with yarpc whatsoever.

from fx.

 avatar commented on May 14, 2024

I think @yutongp caught us in the transition state: we just removed a custom fx.context and haven't fully moved to use the standard one yet.

from fx.

yutongp avatar yutongp commented on May 14, 2024

@alsamylkin I like you guys changed fx to use std context. When I saw that commit, I said 'YES!' to myself. I think std context is definitely the direction to go. appengine used to have custom context and they moved away.

from fx.

ascandella avatar ascandella commented on May 14, 2024

from fx.

yutongp avatar yutongp commented on May 14, 2024

@sectioneight sure, no worries, no rush :D

from fx.

yutongp avatar yutongp commented on May 14, 2024

#239

from fx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.