dedbox
2017-12-5 17:00:29

@notjack checking in with progress on the model


dedbox
2017-12-5 17:01:21

I’ve made some sense of codecs without diving off the “framing” cliff.


dedbox
2017-12-5 17:01:40

Still need to read HTTP2 RFC


dedbox
2017-12-5 17:05:24

Messengers consume the transport API, which deals with byte arrays, so ~transports~ messengers are only useful with codecs that produce or consume byte arrays.


dedbox
2017-12-5 17:06:45

Call a byte array producer an encoder and a byte array consumer a decoder.


dedbox
2017-12-5 17:08:07

Then a messenger is an encoder, a decoder, and a transport.


dedbox
2017-12-5 17:10:15

Now we can think of encoders and decoders as pure functions of type X -> Bs and Bs -> X for any X, and we get composition for free.


dedbox
2017-12-5 17:13:26

So then any unary function can be a “codec.”


dedbox
2017-12-5 17:14:13

Let c be a pure function of type X -> Y, d a decoder of type Bs -> X, and e an encoder of type Y -> Bs.


dedbox
2017-12-5 17:17:45

Then c ○ d : Bs -> Y is also an encoder, and e ○ c : X -> Bs is also a decoder.


dedbox
2017-12-5 17:19:04

Now we can think of generally useful cs, ds, and es.


dedbox
2017-12-5 17:26:53

I think we’re ready to draft some docs and code stubs for URI and Transport APIs, if you wanna wing it on the URI aspect.


dedbox
2017-12-5 17:30:05

So far, a straght forward four-part struct would work: scheme : Symbol authority : Map Symbol String path : List Symbol query : Map Symbol String


dedbox
2017-12-5 17:33:35

If the URI operations handle uri-encoding and -decoding, we have a pretty clean abstraction.


dedbox
2017-12-5 17:35:01

Hrmm… Except maybe the authority part. That’s the ~most complex component~ part I understand least well at this point.


notjack
2017-12-5 19:30:06

conveniently, the authority part is the only part of uris I want to implement for v1


notjack
2017-12-5 19:30:20

it’s the minimal part needed to open connections


dedbox
2017-12-5 19:31:48

d’oh!


notjack
2017-12-5 19:34:42

copying v1 scope from earlier convo for posterity:

  • Data structures and parsers for for IP addresses (v4 and v6), DNS addresses, Racket Transport Addresses, and the parent “registered name” struct, along with authority struct
  • Structs for “prefix-routable address ranges” like CIDR notation and DNS wildcards (*.<http://example.com\|example.com>)
  • Transports, including a generic means of starting and ending an OpenSSL-powered TLS/SSL session over any existing transport with hostname verification in terms of the address range structs above
  • Connectors and listeners, including connection pools

dedbox
2017-12-5 19:44:52

For v1, we can hard wire a simple schema on the dict, e.g., “key host must be associated with a string that [can / must not] be an IP address.”


dedbox
2017-12-5 19:45:53

But the cost is extensibility… maybe we should think that through first.


notjack
2017-12-5 19:48:40

which dict do you mean?


dedbox
2017-12-5 19:51:36

authority


notjack
2017-12-5 19:53:25

ah I was gonna make ip / DNS / others all subtypes of a common reg-name struct


dedbox
2017-12-5 19:55:12

I was overthinking it


dedbox
2017-12-5 19:55:30

The syntax for the authority part is simple.


dedbox
2017-12-5 20:02:08

Protocols can provide their own scheme+authority-&gt;connection-info adapters.


notjack
2017-12-5 20:03:05

pretty much


dedbox
2017-12-5 20:10:24

(re-reading URI RFC now)


dedbox
2017-12-5 20:10:52

So a DNS address is a URI registered name.


dedbox
2017-12-5 20:11:49

The scheme can prescribe registered name resolution semantics.


notjack
2017-12-5 20:12:04

right


dedbox
2017-12-5 20:14:29

In net2, where do we implement scheme-specific behaviors?


notjack
2017-12-5 20:15:50

in some library/package/module specifically for that scheme, I think


notjack
2017-12-5 20:15:57

e.g. http-specific stuff would be in net2/http


dedbox
2017-12-5 20:16:26

So do schemes contain protocols?


notjack
2017-12-5 20:16:40

yes, I think that’s right


dedbox
2017-12-5 20:16:50

Or do protocols consume schemes?


notjack
2017-12-5 20:17:39

the RFC 3986 idea is that a scheme is a definition of how to do stuff with some set of resources


notjack
2017-12-5 20:17:58

every scheme has an RFC that registers it with the IANA


notjack
2017-12-5 20:18:21

and that spec says exactly what the rest of URIs with that scheme can look like and what the bits of it mean


notjack
2017-12-5 20:18:55

a scheme may choose to override parts of the generic URI RFC


notjack
2017-12-5 20:19:11

or may choose to reuse as much of it as possible


notjack
2017-12-5 20:19:42

but the scheme spec is the final say on what URIs with that scheme mean, how to interpret them, and how applications can consume them


notjack
2017-12-5 20:20:15

so a decent way to look at it is that a scheme is a registered specification of some sort of protocol


notjack
2017-12-5 20:21:34

so if somebody sends you a link, like “hey if you want to get in touch with my manager go to <somescheme://somewhere/blah?foo>” the very first thing you have to do is ask yourself “what the hell does somescheme: mean?”


notjack
2017-12-5 20:22:41

if everybody is well-behaved then you can go to the IANA Scheme Registry (https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml) and search for somescheme, then you can find a link to the document registering and defining the scheme


notjack
2017-12-5 20:23:24

not all scheme registrations are descriptive enough to be helpful, but at a minimum a scheme registration has to include contact information (names / email addresses) of somebody you can ask for more information


dedbox
2017-12-5 20:24:03

ok, so the IANA entry for HTTP is a link to the HTTP RFC


notjack
2017-12-5 20:24:09

exactly


dedbox
2017-12-5 20:24:13

that’s easy enough to understand


dedbox
2017-12-5 20:24:44

So we can think of a scheme as a protocol constructor or factory.


dedbox
2017-12-5 20:25:47

and a protocol as a messenger constructor, and a messenger as a transport constructor.


notjack
2017-12-5 20:26:57

There’s a really good RFC that’s a “best practices for new scheme registrations” and it has a lot of info about how to understand schemes


dedbox
2017-12-5 20:27:43

RFC 2718


dedbox
2017-12-5 20:28:03

The URI RFC links to it


dedbox
2017-12-5 20:28:27

heh I just opened it


dedbox
2017-12-5 20:29:49

From RFC 3986: > URI scheme specifications must define their own > syntax so that all strings matching their scheme-specific syntax will > also match the <absolute-URI> grammar


dedbox
2017-12-5 20:30:10

So at least the syntax is predictable.


dedbox
2017-12-5 20:32:58

Ok, so a scheme tells you what the other parts of a URI mean.


dedbox
2017-12-5 20:33:43

Including the protocol(s) necessary to interact with the resource being identified.


notjack
2017-12-5 20:36:54

The RFC I’m thinking of is 7000-something, I think it’s linked to from the “updated by” section at the top of 3986


dedbox
2017-12-5 20:44:01

ah 7320


dedbox
2017-12-5 20:44:10

URI Design and Ownership


notjack
2017-12-5 20:49:06

Yes that’s the one!


notjack
2017-12-5 20:59:11

Wait nope there’s two


notjack
2017-12-5 20:59:18

notjack
2017-12-5 20:59:40

The second is the one I was thinking of that focuses on schemes specifically