COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4....
Transcript of COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4....
![Page 2: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/2.jpg)
COWBOY CHANGES... AGAIN?!WTF man, don't you understand what stable means?
WTF is wrong with you?!
![Page 3: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/3.jpg)
IN THIS TALK1. Why Cowboy 22. Goals3. Low-level
Cowboy4. High-level
Cowboy5. Websocket6. Related projects
![Page 4: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/4.jpg)
WHY COWBOY 2
![Page 5: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/5.jpg)
COWBOY 1 SUCKSIf you are watching this talk, you probably agree.
![Page 6: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/6.jpg)
HTTP/2 REQUIRES A NEW MODELHTTP/2 is concurrent, so Cowboy must also be.
![Page 7: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/7.jpg)
LONG TERM VISIONEven if we are required to make small backward
incompatible changes, overall the Cowboy 2 design willstand the test of time.
You can quote me on that.
![Page 8: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/8.jpg)
INFLUENCESMisultin, HTTP/2, Windows
![Page 9: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/9.jpg)
GOALS
![Page 10: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/10.jpg)
PROTOCOLS SUPPORTEDHTTP/2, HTTP/1.1, Websocket
HTTP/1.0, SPDY/3.1, SPDY/3
![Page 11: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/11.jpg)
MORE POWER TO USERSEverything special processes(proc_lib/sys)Pluggable low-level interfaceTons of options (like Windows!)
![Page 12: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/12.jpg)
SIMPLER INTERFACELess, simpler callbacksNo more dealing with Req objectExtract, validate and convert input in onestepMaps. Maps everywhere!
![Page 13: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/13.jpg)
BETTER CODEAll parsing code will be in Cowlib.
Cowboy will deal strictly with protocol logic and its ownfeatures.
![Page 14: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/14.jpg)
TESTS TESTS TESTSProperty based testing of CowlibFunctional testing of Cowboy protocols andfeatures
![Page 15: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/15.jpg)
LOW-LEVEL COWBOY
![Page 16: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/16.jpg)
PERFORMANCEDo as little as possible, allocate as little as possible, and
provide a pluggable interface for power users.
![Page 17: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/17.jpg)
USE CASESProxies (CONNECT or otherwise)FrameworksLow-level protocols (Websocket)HooksHandling high demand resourcesearly
![Page 18: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/18.jpg)
THE BIG PICTUREConnection → Protocol → Streams
![Page 19: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/19.jpg)
CONNECTIONcowboy_clearcowboy_tls
![Page 20: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/20.jpg)
LISTENER STARTUPcowboy:start_clear(Name, Nb, TransOpts,ProtoOpts)cowboy:start_tls(Name, Nb, TransOpts, ProtoOpts)
![Page 21: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/21.jpg)
CHOICE OF PROTOCOLcowboy_clear → cowboy_http
cowboy_tls → ALPN → Protocol
cowboy_httpcowboy_http2cowboy_spdy
![Page 22: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/22.jpg)
ALPN?1. Client advertises list of protocols it
supports2. Server chooses protocol and informs client
Erlang/OTP 18+
![Page 23: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/23.jpg)
PROTOCOL MODULESCommon interfaceNon-blockingHandles system messagesAble to act as a supervisor if stream-based
![Page 24: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/24.jpg)
PROTOCOL UPGRADESSame mechanism for:
Upgrading from HTTP/1.1 to HTTP/2Upgrading from HTTP/1.1 to WebsocketUpgrading HTTP/1.1 connections from TCP toTLS
![Page 25: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/25.jpg)
STREAMSA stream is an HTTP request/response pair identified by a
unique stream identifier.
A stream can be initiated by the server using a promise.
![Page 26: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/26.jpg)
STREAM-BASED PROTOCOLScowboy_httpcowboy_http2cowboy_spdy(cowboy_coap?)NOTcowboy_websocket
![Page 27: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/27.jpg)
STREAM HANDLERinit(ID, IsFin, Method, Scheme, Host, Path, Headers,Opts)data(ID, IsFin, Data, State)info(ID, Msg, State)terminate(ID, Reason, State)
![Page 28: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/28.jpg)
STREAM-SPECIFIC MESSAGESMessages are filtered per-stream{{Handler, ID}, Msg}{{Handler, ID}, From, Msg}
![Page 29: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/29.jpg)
STREAM COMMANDS{response, IsFin, StatusCode, Headers}{data, IsFin, Data}{promise, Method, Scheme, Authority, Path,Headers}{flow, auto | Size}{spawn, Pid}{upgrade, Mod, Opts}
![Page 30: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/30.jpg)
DEFAULT STREAM HANDLERCreates a new process per streamCommunicates with process using Cowboy streamprotocolHigh-level Cowboy
![Page 31: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/31.jpg)
ONE PROCESS PER REQUESTHigh-level Cowboy uses 1 proc/conn + 1proc/streamBUTLow-level Cowboy uses 1 proc/conn only
![Page 32: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/32.jpg)
COWBOY STREAM PROTOCOL{response_header, Key, Value}{response_cookie, Key, Value, Opts}{response_body, Body}{response, IsFin, StatusCode, Headers}{data, IsFin, Data}{promise, Method, Scheme, Authority, Path,Headers}{data_request, Size}
![Page 33: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/33.jpg)
LAYERED STREAM HANDLERSA stream handler can call another stream handlerUse handler-specific options to define the nextlayerThis makes Cowboy 1 hooks worthless
![Page 34: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/34.jpg)
HIGH-LEVEL COWBOY
![Page 35: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/35.jpg)
CONVENIENCEPie tastes good, right? Just like Cowboy 2.
Favor convenience, elegance and simplicity. No pitfalls.Straightforward.
![Page 36: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/36.jpg)
THE BIG PICTUREMiddlewares → User handlers
Default: cowboy_router → cowboy_handler
![Page 37: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/37.jpg)
MIDDLEWARESNo more 'error' tuple; ok, suspend, stop
![Page 38: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/38.jpg)
ROUTINGI would like to solve the fact that routing rules are copied to
all connection processes. Perhaps ets?
![Page 39: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/39.jpg)
REVERSE ROUTINGRequired for better HATEOAS support.
Give module name and bindings, get URL.Add query string to URL (optional).
![Page 40: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/40.jpg)
CONSTRAINTSUse constraints all across high-level Cowboy.
Improve error handling interface, add human errors.
![Page 41: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/41.jpg)
HANDLERSUnify init and terminate callbacks
Simplify init return value: {ok | Mod, State}
Do everything in init/2
![Page 42: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/42.jpg)
REST HANDLERSAdd behaviour with optional callbacks
Remove known_content_type callback
![Page 43: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/43.jpg)
REQ OBJECTImmutable
3 levels of access to values:
Raw valueParsed valueMatchedvalue
![Page 44: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/44.jpg)
MATCH FUNCTIONSExtract, validate and convert values in one step.
#{lang := Lang} = cowboy_req:match_qs( [{lang, nonempty, <<"enUS">>}], Req)
![Page 45: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/45.jpg)
ADDITIONAL NOTESHandler suffix becomes _h
Settle on 'stop' instead of 'shutdown' or 'halt'
Cowlib provides parsers for nearly everything
![Page 46: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/46.jpg)
WEBSOCKET
![Page 47: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/47.jpg)
UPGRADEFrom stream handlerFrom requestprocess
Connection process switches to Websocket protocol
![Page 48: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/48.jpg)
FEATURESWebsocket permessage-deflate support added.
Websocket UTF-8 validation optimized.An option to disable validation will be added.
![Page 49: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/49.jpg)
WEBSOCKET HANDLERSNo more websocket_initNo morewebsocket_terminateOptional terminateNo keeping track of Req
![Page 50: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/50.jpg)
RELATED PROJECTS
![Page 51: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/51.jpg)
RANCH 2Merge acceptor and supervisorfunctionalityUse the async accept mechanism
![Page 52: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/52.jpg)
GUNGun is an asynchronous HTTP client with support for
HTTP/1.1, HTTP/2, SPDY/3 and Websocket, designed forlong-running connections.
![Page 53: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/53.jpg)
ERLANG.MKErlang.mk is a Makefile based build tool that just works.
No Makefile knowledge required to use it
![Page 54: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/54.jpg)
WHY ERLANG.MKMy users need a build tool that actually works.
![Page 55: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/55.jpg)
CONVINCE MECompatible with a lot more projects than rebarDependencies can be in any language (C,Javascript...)It's just a text file
![Page 56: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/56.jpg)
COMPLEXITY COMPARISONRebar feature Erlang.mk equivalent
rebar.config variables
rebar.config.script variables and/or rules
rebar hook rules
rebar2 plugin rules
rebar3 plugin rules
![Page 57: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/57.jpg)
ERLANG.MK INDEXGetting close to 450 projects
DEPS = cowboy cpg erlydtl riak_core
![Page 58: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/58.jpg)
ALL PACKAGES 1/6aberth active aleppo alog annotations antidote apns azdht
backoff barrel basho_bench bcrypt beam beanstalk bearbertconf bifrost binpp bisect bitcask bitstore bootstrap
boss_db boss bson bullet cache cake carotene cberl cechocferl chaos_monkey check_node chronos classifier clique
cloudi_core cloudi_service_* cluster_info color confetticouchbeam couch covertool cowboy cowdb cowlib cpgcqerl cr cuttlefish damocles debbie decimal detergent
dh_date dhtcrawler dirbusterl dispcount dlhttpc dns dnssddtl dynamic_compile e2 eamf eavro ecapnp econfig edate
edgar edis edns
![Page 59: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/59.jpg)
ALL PACKAGES 2/6edown eep_app eep efene eganglia egeoip ehsa ejabberd ej
ekaf elarm eleveldb elli elvis emagick emysql enm entopepcap eper epgsql episcina eplot epocxy epubnub eqm
eredis eredis_pool erlang_cep erlang_js erlang_localtimeerlang_smtp erlasticsearch erlastic_search erlbrake erlclouderlcron erldb erldis erldns erldocker erlfsmon erlgit erlguten
erlmc erlmongo erlog erlpass erlport erlsha2 erlsh erlsomerl_streams erlubi erlvolt erlware_commons erlydtl errderserve erwa espec estatsd etap etest etest_http etoml
eunit_formatters eunit euthanasia evum exec exmlexometer exs1024 exs64 exsplus116 exsplus128 ezmq ezmtp
![Page 60: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/60.jpg)
ALL PACKAGES 3/6fast_disk_log feeder fix flower fn folsom_cowboy folsom
folsomite fs fuse gcm gcprof geas geef gen_cycle gen_icmpgen_nb_server gen_paxos gen_smtp gen_tracker gen_unixgetopt gettext giallo gin gitty gold_fever gpb gproc grapherl
gun hackney hamcrest hanoidb hottub hyper ibrowseierlang iota ircd irc_lib iris iso8601 itweet jerg jesse jiffyjiffy_v jobs joxa jsonerl json jsonpath json_rec jsonx jsxkafka kai katja kdht kinetic kjell kraken kucumberl kvc
kvlists kvs lager_amqp_backend lager lager_sysloglambdapad lasp lasse ldap lethink lfe ling live lmq locker
locks log4erl lol lucid luerl luwak lux mad mavg mcdmcerlang mc_erl meck
![Page 61: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/61.jpg)
mcerlang mc_erl meck
ALL PACKAGES 4/6mekao memo merge_index merl mimetypes mixer
mochiweb mochiweb_xpath mockgyver modlib mongodbmongooseim moyo msgpack mustache myproto mysql n2o
nat_upnp neo4j neotoma newrelic nifty nitrogen_corenkbase nkdocker nkpacket nodefinder nprocreg oauth2c
oauth2 oauth of_protocol openflow openid openpoker palparse_trans parsexml pegjs percept2 pgsql pkgx pkt
plain_fsm plumtree pmod_transform pobox ponos poolboypooler poxa pqueue procket proper props protobuffs
psycho ptrackerl purity push_service qdate qrcode questrabbit_exchange_type_riak rack radierl rafter ranch
![Page 62: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/62.jpg)
ALL PACKAGES 5/6rbeacon rebar rebus rec2json recon record_info redgridredo relx resource_discovery restc rfc4627_jsonrpc riakc
riak_core riak_dt riak_ensemble riakhttpc riak_kv riaknosticriak_pg riak_pipe riakpool riak_sysmon riak_test rivus_ceprlimit safetyvalve seestar service setup sext sfmt sgte sheriff
shotgun sidejob sieve sighandler simhash simple_bridgesimple_oauth2 skel social spapi_router sqerl srly sshrpc
stable statebox statebox_riak statman statsderlstdinout_pool stockdb stripe surrogate swab swarm
switchboard sync syntaxerl syslog taskforce tddreloadertempo ticktick tinymq tinymt traffic_tools trane transit trie
![Page 63: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/63.jpg)
ALL PACKAGES 6/6triq tunctl twerl twitter_erlang ucol_nif unicorn unsplit uuid
ux vert verx vmq_acl vmq_bridge vmq_graphitevmq_passwd vmq_server vmq_snmp vmq_systree vmstats
walrus webmachine websocket_client worker_poolwrangler wsock xref_runner yamerl yamler yaws zab_engine
zeta zippers zlists zraft_lib zucchini
![Page 64: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/64.jpg)
ERLANG.MK PLANS 1/21. Compile everything2. Keep track of versions3. Provide curated
packages
![Page 65: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/65.jpg)
ERLANG.MK PLANS 2/21. Add support for LFE, Elixir projects2. Add Concuerror, Chaos Monkey, Smother,
RefactorErl...3. Generate the .app file without a .app.src
![Page 66: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/66.jpg)
EVERYTHING IN THE MAKEFILEPROJECT → application namePROJECT_DESCRIPTION → descriptionPROJECT_VERSION → vsnPROJECT_ID → idPROJECT_TYPE → mod, registeredPROJECT_REGISTERED → registeredPROJECT_ENV or PROJECT_ENV_FILE → envmodules list automatically filledapplications list automatically filled fromDEPS
![Page 67: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/67.jpg)
EVERYTHING OPTIONALAll the variables that ultimately build the .app file are either
optional or automatically defined when bootstrapping.
Adding a dependency becomes a one step process.
![Page 68: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/68.jpg)
STARTING UP GOALSmkdir kitty; cd kittywget $ERLANG_MK_URLmake -f bootstrap bootstrap-relappend DEPS = cowboy cpg erlydtlriak_coremake run
![Page 69: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/69.jpg)
STARTING UP LATER GOALSerlang-mk new kittyappend DEPS = cowboy cpg erlydtlriak_coremake run
![Page 70: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/70.jpg)
ERLANG.MK ON WINDOWSMake 4 makes supporting Windows possible without
needing the whole Unix toolchain.
Before this there are much bigger Windows issues to solveto make the experience smooth, unrelated to Erlang.mk
![Page 71: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/71.jpg)
THE ERLANGER PLAYBOOKThis book is the missing developer manual. It contains
advice from my experience working with Cowboy.
Price: 50€
Ebook preorder available soon on ninenines.eu
Want to buy it today and get it right now? Come talk to meor send an email later at [email protected]
![Page 72: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/72.jpg)
TERMINATE
![Page 73: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/73.jpg)
TL;DRCowboy 2's design is long term.
![Page 74: COWBOY 2 - erlang-factory.com · IN THIS TALK 1. Why Cowboy 2 2. Goals 3. Low-level Cowboy 4. High-level Cowboy 5. Websocket 6. Related projects](https://reader030.fdocuments.in/reader030/viewer/2022040204/5ec5a2fc69d7b460ea09af1c/html5/thumbnails/74.jpg)
QUESTIONS?To look at an early release of the code in this talk:
tag 2.0.0-pre.2
To buy the book, access projects:ninenines.eu
To follow my exciting adventures:@lhoguin on Twitter
To ask questions, talk about hats:#ninenines on Freenode