Repository navigation
Releases: sean3z/crocket
Releases · sean3z/crocket
Release list
crocket 0.3.0
Databases: crocket::db with its Postgres backend crocket::pg, and handlers that
return plain structs. Nothing existing breaks; the new pieces are opt-in.
Added
crocket::db, a small database API, with its first backendcrocket::pg
(CMake target), Postgres on libpqxx, built when libpqxx is found
(-DCROCKET_PG=AUTO|ON|OFF). Handlers takeDb&and never name the backend. Plain structs, no annotations or base class: the
table is the type's name in plural snake_case (Hero->heroes, overridable with
db::table_name<T>), columns are the members,idis the key. Handlers takeDb& db;
db.find<T>(id),db.insert(v),db.update(v),db.erase<T>(id),
db.where(&T::member, value | db::like(...) | db::gt(...) | db::in({...}))with
order_by,limit,offset,all,firstandcount, plusdb.sql<T>(...)and
db.exec(...)for raw SQL. Statements are prepared once per connection.- A model's
idmay be missing from a JSON body (it reads as 0 and the database
assigns it);insert()never sendsid, so a client-supplied one is ignored.
json::omittable<T>is the hook. crocket_db_seconds{table,op}andcrocket_db_pool_connections{state}in
Metrics, anddb_ms,db_wait_msanddb_queriesonLoggerrequest lines,
when a request used the database.Config::database(url,pool_size,pool_wait) andCROCKET_DATABASE_URL,
CROCKET_DATABASE_POOL_SIZEandCROCKET_DATABASE_POOL_WAITinConfig::from_env().- Handlers can return a plain struct:
Hero,std::vector<Hero>,std::optional<Hero>
(empty: 404) andCreated<Hero>are JSON on HTTP routes, as if wrapped inJson<T>,
and protobuf on gRPC routes.Json<T>still works and always wins. Proto<T>: an explicit protobuf body,application/x-protobufon HTTP routes and
the normal reply on gRPC routes. A gRPC method returningJson<T>replies with JSON
(application/grpc+json). OpenAPI listsapplication/x-protobufforProto<T>.examples/heroes.cpp: a CRUD API oncrocket::db, andbench/db.cpp,crocket::db
against the same queries written with libpqxx.
crocket 0.2.0
One Config for everything, configurable from the environment. Breaking: settings
moved, so code that sets them needs the new names.
Changed
LaunchOptionsis gone;Configholds every setting, in groups:server
(listen,host,port,workers,event_loops,tls_cert,tls_key,http2,
h2_prior_knowledge),limits(max_body_bytes,max_body_memory,max_in_flight,
max_header_bytes,max_header_count,max_connections,max_connections_per_ip,
http2_max_streams,etag_max_bytes),timeouts(request,drain) andproxy
(trusted,header,allowed_hosts), plusprofile,debug_routes,json,log
andadaptive_placement. Having two structs made it unclear where a setting lived
and which of them the environment reached.launch()serves oncfg.server;launch({...})takesServerOverrides, which
overrides only the server fields you name:.launch({.listen = "8080"}).
listenaccepts"8080",":8080","host:8080"and"[::1]:8080".Config::from_env()reads everyCROCKET_*setting, not justCROCKET_PROFILE,
with strict parsing: a bad value throwsstd::invalid_argumentnaming the variable
(CROCKET_PORT=tcp://10.43.0.12:8000is rejected instead of misread).
Config::from_env(base)layers the profile and environment over your own defaults.
Precedence: defaults < base < profile < environment < code <launch({...}).CROCKET_REQUEST_TIMEOUTaccepts units (500ms,30s,2m); a bare number is still
seconds.CROCKET_DEBUG_ROUTESis a boolean now:0/falseturns it off.examples/serve.cpp,grpc.cppandhello.cppuseConfig::from_env()and
launch()instead of mapping variables by hand.
Migrating from 0.1
| 0.1 | 0.2 |
|---|---|
cfg.request_timeout, cfg.drain_timeout |
cfg.timeouts.request, cfg.timeouts.drain |
cfg.max_body_bytes, max_in_flight, max_body_memory, etag_max_bytes |
cfg.limits.* |
cfg.trusted_proxies, proxy_header, allowed_hosts |
cfg.proxy.trusted, .header, .allowed_hosts |
LaunchOptions{.max_connections = ...} and the other limits |
cfg.limits.* |
.launch({.host = ..., .port = ..., .tls_cert = ...}) |
unchanged, or cfg.server.* and .launch() |
Hand-written getenv("CROCKET_...") |
Config::from_env() |
crocket 0.1.1
The first tagged release: the stable channel starts here.
Added
- Versions and release channels:
project(crocket VERSION 0.1.1), a generated
<crocket/version.hpp>(crocket::version::string,commit,compiler), and a
release workflow that publishesghcr.io/sean3z/crocket-helloas:X.Y.Z,:X.Yand
:stablefor release tags,:latestand:sha-<short>formain, and
:experimentalforX.Y.Z-rc.Npre-releases (#31). crocket_build_info{version,commit,compiler,hostname} 1inMetrics(#31).- Constant labels on every metrics series via
CROCKET_METRICS_LABELS
(for examplepod=$(POD_NAME)), orMetrics{path, {{"pod", ...}}}(#31). - GCC 16.2 toolchain image (
ghcr.io/sean3z/crocket-toolchain:gcc-16.2) for CI and dev containers. crocket-helloimage, a Compiler Explorer example and a "Try it" section in the README.docs/DESIGN.md, describing crocket as it is.
Changed
- CI runs in the toolchain image instead of building GCC (about 29 minutes down to 3).
-freflectionis added only for GCC, and configure fails early with a clear message
when the compiler lacks C++26 reflection (#20, #21, #28).- README: FetchContent pins a release tag (#22, #29).
Fixed
- Metrics: 504 deadline responses are labelled with their matched route instead of
<unmatched>(#30).