Eve Networking
Networking is how an Eve program talks to other machines: to find them, to connect to them and to move bytes. Eve 0.1 has no network access. This page collects what the design needs and what is still to decide, so that the next pages of the tutorial (Protocols, Server) rest on one picture.
Not designed yet. Nothing on this page is part of the language. Names are proposals to discuss (Q-028).
The layers
| Layer | What it does | In Eve |
|---|---|---|
| names and addresses | a host name becomes an address | a Url type and a resolver: planned |
| connection | TCP or QUIC, with TLS for secrecy | the module net: planned |
| protocol | the rules of a conversation: HTTP, EWP | see Protocols |
| data | the bytes become values: JSON, CSV, binary | the modules json, csv: planned |
| application | what the program does with the data | drivers, aspects, jobs |
Eve as a client
The first step is to call other systems: fetch a file, call a REST service, send a result. The calls wait for the network, and while a task waits it gives the turn away, so the tasks of one job can overlap many requests (see Multitasking), and aspects started in a parallel group can spread them on several cores (see Concurrency).
** proposed: the module net, a request and its answer
from "lib" use (http);
new answer := http.get("https://api.example.com/orders", timeout: 10s);
expect answer.status == 200;
print answer.body;
Eve as a server
The same machine can answer requests: static files, JSON and HTML routes handled by aspects. The design is on the Server page.
Safety
- Capabilities: a project declares what it may reach (
net: "api.example.com"); an aspect declares what it needs; the machine refuses the rest. A browser machine reaches only its own origin; - Secrets: a token or password is a
Secret, never printed and never written to a log; it goes only to its sink; - Time-outs: every network call has a time-out (
$timeoutby default) and raises an error when it passes; - TLS: a connection to another machine is encrypted; a certificate that does not match is an error, not a warning.
Not designed yet. Sockets or only protocols; the type
Url; DNS; proxies; how a project file declares capabilities; the error classes of the network (NetError, TimeoutError).TODO: decide the level: the version map puts the HTTP client at level 3 and the server at level 6; write the page again after Q-028.
TODO: add the "downloading" example: a generator that reads a large answer in chunks (see Generators).
TODO: describe retries with jobs and the idempotency key, and the rate limit of a service.
TODO: write the security section from the review: certificates, redirects to another host, size limits, and what a script may not do with a URL it received.
Read next: Protocols