MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / run

Function run

src/persist-cli/src/open_loop.rs:107–167  ·  view source on GitHub ↗
(args: Args)

Source from the content-addressed store, hash-verified

105const MIB: u64 = 1024 * 1024;
106
107pub async fn run(args: Args) -> Result<(), anyhow::Error> {
108 let metrics_registry = MetricsRegistry::new();
109 {
110 let metrics_registry = metrics_registry.clone();
111 info!(
112 "serving internal HTTP server on http://{}/metrics",
113 args.internal_http_listen_addr
114 );
115 let listener = TcpListener::bind(&args.internal_http_listen_addr)
116 .await
117 .expect("can bind");
118 mz_ore::task::spawn(
119 || "http_server",
120 axum::serve(
121 listener,
122 axum::Router::new()
123 .route(
124 "/metrics",
125 axum::routing::get(move |headers: axum::http::HeaderMap| async move {
126 mz_http_util::handle_prometheus(&metrics_registry, headers).await
127 }),
128 )
129 .into_make_service(),
130 )
131 .into_future(),
132 );
133 }
134
135 let location = PersistLocation {
136 blob_uri: args.blob_uri.clone(),
137 consensus_uri: args.consensus_uri.clone(),
138 };
139 let persist = PersistClientCache::new(
140 PersistConfig::new_default_configs(&mz_persist_client::BUILD_INFO, SYSTEM_TIME.clone()),
141 &metrics_registry,
142 |_, _| PubSubClientConnection::noop(),
143 )
144 .open(location)
145 .await?;
146
147 let shard_id = match args.shard_id.clone() {
148 Some(shard_id) => ShardId::from_str(&shard_id).map_err(anyhow::Error::msg)?,
149 None => ShardId::new(),
150 };
151
152 let metrics = Arc::clone(persist.metrics());
153 let (writers, readers) = match args.benchmark_type.clone() {
154 BenchmarkType::RawWriter => {
155 raw_persist_benchmark::setup_raw_persist(
156 persist,
157 shard_id,
158 args.num_writers,
159 args.num_readers,
160 )
161 .await?
162 }
163 BenchmarkType::MzSourceModel => panic!("source model"),
164 };

Callers

nothing calls this directly

Calls 13

spawnFunction · 0.85
handle_prometheusFunction · 0.85
cloneFunction · 0.85
setup_raw_persistFunction · 0.85
expectMethod · 0.80
routeMethod · 0.80
run_benchmarkFunction · 0.70
serveFunction · 0.50
getFunction · 0.50
cloneMethod · 0.45
into_futureMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected