Loïc Hoguin (@lhoguin), Nine Nines
WTF man, don't you understand what stable means?
WTF is wrong with you?!
If you are watching this talk, you probably agree.
HTTP/2 is concurrent, so Cowboy must also be.
Even if we are required to make small backward incompatible changes, overall the Cowboy 2 design will stand the test of time.
You can quote me on that.
Misultin, HTTP/2, Windows
HTTP/2, HTTP/1.1, Websocket
HTTP/1.0, SPDY/3.1, SPDY/3
All parsing code will be in Cowlib.
Cowboy will deal strictly with protocol logic and its own features.
Do as little as possible, allocate as little as possible, and provide a pluggable interface for power users.
Connection → Protocol → Streams
cowboy_clear → cowboy_http
cowboy_tls → ALPN → Protocol
Erlang/OTP 18+
Same mechanism for:
A stream is an HTTP request/response pair identified by a unique stream identifier.
A stream can be initiated by the server using a promise.
Pie tastes good, right? Just like Cowboy 2.
Favor convenience, elegance and simplicity. No pitfalls. Straightforward.
Middlewares → User handlers
Default: cowboy_router → cowboy_handler
No more 'error' tuple; ok, suspend, stop
I would like to solve the fact that routing rules are copied to all connection processes. Perhaps ets?
Required for better HATEOAS support.
Give module name and bindings, get URL.
Add query string to URL (optional).
Use constraints all across high-level Cowboy.
Improve error handling interface, add human errors.
Unify init and terminate callbacks
Simplify init return value: {ok | Mod, State}
Do everything in init/2
Add behaviour with optional callbacks
Remove known_content_type callback
Immutable
3 levels of access to values:
Extract, validate and convert values in one step.
#{lang := Lang} = cowboy_req:match_qs(
[{lang, nonempty, <<"en-US">>}], Req)
Handler suffix becomes _h
Settle on 'stop' instead of 'shutdown' or 'halt'
Cowlib provides parsers for nearly everything
Connection process switches to Websocket protocol
Websocket permessage-deflate support added.
Websocket UTF-8 validation optimized.
An option to disable validation will be added.
Gun is an asynchronous HTTP client with support for HTTP/1.1, HTTP/2, SPDY/3 and Websocket, designed for long-running connections.
Erlang.mk is a Makefile based build tool that just works.
No Makefile knowledge required to use it
My users need a build tool that actually works.
Rebar feature | Erlang.mk equivalent |
---|---|
rebar.config | variables |
rebar.config.script | variables and/or rules |
rebar hook | rules |
rebar2 plugin | rules |
rebar3 plugin | rules |
Getting close to 450 projects
DEPS = cowboy cpg erlydtl riak_core
aberth active aleppo alog annotations antidote apns azdht backoff barrel basho_bench bcrypt beam beanstalk bear bertconf bifrost binpp bisect bitcask bitstore bootstrap boss_db boss bson bullet cache cake carotene cberl cecho cferl chaos_monkey check_node chronos classifier clique cloudi_core cloudi_service_* cluster_info color confetti couchbeam couch covertool cowboy cowdb cowlib cpg cqerl cr cuttlefish damocles debbie decimal detergent dh_date dhtcrawler dirbusterl dispcount dlhttpc dns dnssd dtl dynamic_compile e2 eamf eavro ecapnp econfig edate edgar edis edns
edown eep_app eep efene eganglia egeoip ehsa ejabberd ej ekaf elarm eleveldb elli elvis emagick emysql enm entop epcap eper epgsql episcina eplot epocxy epubnub eqm eredis eredis_pool erlang_cep erlang_js erlang_localtime erlang_smtp erlasticsearch erlastic_search erlbrake erlcloud erlcron erldb erldis erldns erldocker erlfsmon erlgit erlguten erlmc erlmongo erlog erlpass erlport erlsha2 erlsh erlsom erl_streams erlubi erlvolt erlware_commons erlydtl errd erserve erwa espec estatsd etap etest etest_http etoml eunit_formatters eunit euthanasia evum exec exml exometer exs1024 exs64 exsplus116 exsplus128 ezmq ezmtp
fast_disk_log feeder fix flower fn folsom_cowboy folsom folsomite fs fuse gcm gcprof geas geef gen_cycle gen_icmp gen_nb_server gen_paxos gen_smtp gen_tracker gen_unix getopt gettext giallo gin gitty gold_fever gpb gproc grapherl gun hackney hamcrest hanoidb hottub hyper ibrowse ierlang iota ircd irc_lib iris iso8601 itweet jerg jesse jiffy jiffy_v jobs joxa jsonerl json jsonpath json_rec jsonx jsx kafka kai katja kdht kinetic kjell kraken kucumberl kvc kvlists kvs lager_amqp_backend lager lager_syslog lambdapad lasp lasse ldap lethink lfe ling live lmq locker locks log4erl lol lucid luerl luwak lux mad mavg mcd mcerlang mc_erl meck
mekao memo merge_index merl mimetypes mixer mochiweb mochiweb_xpath mockgyver modlib mongodb mongooseim moyo msgpack mustache myproto mysql n2o nat_upnp neo4j neotoma newrelic nifty nitrogen_core nkbase nkdocker nkpacket nodefinder nprocreg oauth2c oauth2 oauth of_protocol openflow openid openpoker pal parse_trans parsexml pegjs percept2 pgsql pkgx pkt plain_fsm plumtree pmod_transform pobox ponos poolboy pooler poxa pqueue procket proper props protobuffs psycho ptrackerl purity push_service qdate qrcode quest rabbit_exchange_type_riak rack radierl rafter ranch
rbeacon rebar rebus rec2json recon record_info redgrid redo relx resource_discovery restc rfc4627_jsonrpc riakc riak_core riak_dt riak_ensemble riakhttpc riak_kv riaknostic riak_pg riak_pipe riakpool riak_sysmon riak_test rivus_cep rlimit safetyvalve seestar service setup sext sfmt sgte sheriff shotgun sidejob sieve sighandler simhash simple_bridge simple_oauth2 skel social spapi_router sqerl srly sshrpc stable statebox statebox_riak statman statsderl stdinout_pool stockdb stripe surrogate swab swarm switchboard sync syntaxerl syslog taskforce tddreloader tempo ticktick tinymq tinymt traffic_tools trane transit trie
triq tunctl twerl twitter_erlang ucol_nif unicorn unsplit uuid ux vert verx vmq_acl vmq_bridge vmq_graphite vmq_passwd vmq_server vmq_snmp vmq_systree vmstats walrus webmachine websocket_client worker_pool wrangler wsock xref_runner yamerl yamler yaws zab_engine zeta zippers zlists zraft_lib zucchini
All the variables that ultimately build the .app file are either optional or automatically defined when bootstrapping.
Adding a dependency becomes a one step process.
Make 4 makes supporting Windows possible without needing the whole Unix toolchain.
Before this there are much bigger Windows issues to solve to make the experience smooth, unrelated to Erlang.mk
This 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 me or send an email later at essen@ninenines.eu
Cowboy 2's design is long term.
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