martin/benches/sources.rs
Yuri Astrakhan 66b7fdc4ea
Multi-source support, new path structure (#456)
Partial implementation of the #430

* New endpoint structure:
  * `GET /` -- a placeholder for the future home page
* `GET /catalog` -- get a list of available sources, as a list of json
blobs.
* `[{id, name, description, attribution, vector_layer}, ...]` (some
fields might be missing)
* `GET /<id>` -- get tilejson for the given source, or a combination of
sources. No `.json` extension
  * `GET /<id>/<z>/<x>/<y>` -- get a tile. No format extension.
  * `GET /health` -- healthcheck
* Introduce a new tile format support crate (using code from the
maplibre/mbtileserve project)
* Removed the `/rpc/...` routes - all source IDs are accessed in the
same way
* Can print auto-generated configuration or save it to a file
* Refactored to support multiple sources from multiple backends, with a
proper naming conflict resolution

TODO:
* benchmarks need to be rewritten - they were relying on some internal
structures that are no longer there. This might be done as a separate PR
due to a very different internal architecture - might need to rethink
benchmarking approaches.
2022-11-26 04:46:40 -05:00

117 lines
3.8 KiB
Rust

fn main() {}
// use std::collections::HashMap;
//
// use criterion::{criterion_group, criterion_main, Criterion};
// use martin::pg::function_source::{FunctionInfo, FunctionSource};
// use martin::pg::table_source::{TableInfo, TableSource};
// use martin::source::{Source, Xyz};
//
// #[path = "../tests/utils.rs"]
// mod utils;
// use utils::*;
//
// async fn mock_table_source(schema: &str, table: &str) -> TableSource {
// TableSource::new(
// format!("{schema}.{table}"),
// TableInfo {
// schema: schema.to_owned(),
// table: table.to_owned(),
// id_column: None,
// geometry_column: "geom".to_owned(),
// minzoom: None,
// maxzoom: None,
// bounds: None,
// srid: 3857,
// extent: Some(4096),
// buffer: Some(64),
// clip_geom: Some(true),
// geometry_type: None,
// properties: HashMap::new(),
// unrecognized: HashMap::new(),
// },
// mock_pool().await,
// )
// }
//
// fn mock_function_source(schema: &str, function: &str) -> FunctionSource {
// // id: format!("{schema}.{function}"),
// FunctionInfo {
// schema: schema.to_owned(),
// function: function.to_owned(),
// minzoom: None,
// maxzoom: None,
// bounds: None,
// unrecognized: HashMap::new(),
// }
// }
//
// async fn get_table_source() {
// let source = mock_table_source("public", "table_source").await;
// let _tilejson = source.get_tilejson();
// }
//
// async fn get_table_source_tile() {
// let source = mock_table_source("public", "table_source").await;
// let xyz = Xyz { z: 0, x: 0, y: 0 };
// let _tile = source.get_tile(&xyz, &None).await.unwrap();
// }
//
// async fn get_composite_source() {
// let points1 = mock_table_source("public", "points1");
// let points2 = mock_table_source("public", "points2");
//
// let source = CompositeSource {
// id: "public.points1,public.points2".to_owned(),
// table_sources: vec![points1, points2],
// };
//
// let _tilejson = source.get_tilejson();
// }
//
// async fn get_composite_source_tile() {
// let points1 = mock_table_source("public", "points1");
// let points2 = mock_table_source("public", "points2");
//
// let source = CompositeSource {
// id: "public.points1,public.points2".to_owned(),
// table_sources: vec![points1, points2],
// };
//
// let xyz = Xyz { z: 0, x: 0, y: 0 };
// let _tile = source.get_tile(&xyz, &None).await.unwrap();
// }
//
// async fn get_function_source() {
// let source = mock_function_source("public", "function_source");
// let _tilejson = source.get_tilejson();
// }
//
// async fn get_function_source_tile() {
// let source = mock_function_source("public", "function_source");
// let xyz = Xyz { z: 0, x: 0, y: 0 };
//
// let _tile = source.get_tile(&xyz, &None).await.unwrap();
// }
//
// fn table_source(c: &mut Criterion) {
// c.bench_function("get_table_source", |b| b.iter(get_table_source));
// c.bench_function("get_table_source_tile", |b| b.iter(get_table_source_tile));
// }
//
// fn composite_source(c: &mut Criterion) {
// c.bench_function("get_composite_source", |b| b.iter(get_composite_source));
// c.bench_function("get_composite_source_tile", |b| {
// b.iter(get_composite_source_tile);
// });
// }
//
// fn function_source(c: &mut Criterion) {
// c.bench_function("get_function_source", |b| b.iter(get_function_source));
// c.bench_function("get_function_source_tile", |b| {
// b.iter(get_function_source_tile);
// });
// }
//
// criterion_group!(benches, table_source, composite_source, function_source);
// criterion_main!(benches);