Sign in

software engineer at auth0, writing code for humans, with humans.

Hypothetical Client: Runtime

Let’s imagine we have a hypothetical Runtime client with just one public method:


What I love about net/http

The two things which stand out for me are:

  1. Interface Design.
  2. Composability

Interface Design

The primary constructs you’ll interact with are pretty limited:

http.Handler
http.HandlerFunc
http.Server
http.ResponseWriter
http.Request
http.Client
http.Transport


Definitions

Dependency injection represents the D in SOLID principles. Quoting from wikipedia:


done := make(chan struct{})for {
select {
case <-done:
return
case job := <-jobs:
// execute job
}
}

Approaches to closing this done channel

Option 1: using a mutex

If we take a look at how it’s done in the context package, it simply uses a mutex to ensure that the action of closing the channel is only done once.

Cyril David

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store