Skip to content

Commit

Permalink
Rename fpx to fpx-cli and fpx-lib to fpx (#446)
Browse files Browse the repository at this point in the history
* Rename fpx to fpx-cli and fpx-lib to fpx

* Update cargo alias

* Fix build

* Refactor ApiClientErrors

* Move ApiClientError related tests to its module
  • Loading branch information
hatchan authored Jan 21, 2025
1 parent 3fb971e commit 5a16788
Show file tree
Hide file tree
Showing 59 changed files with 1,080 additions and 1,254 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[alias]
fpx = "run --package fpx --"
fpx = "run --package fpx-cli --"
xtask = "run --package xtask --"
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ jobs:
run: cargo test

- name: cargo build
run: cargo build --release
run: cargo build --release --package fpx-cli

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: fpx_${{ matrix.target }}
path: target/release/fpx
path: target/release/fpx-cli
if-no-files-found: error
retention-days: 7
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[workspace]
resolver = "2"
members = ["fpx", "fpx-lib", "fpx-workers", "fpx-macros", "xtask"]
default-members = ["fpx"]
members = ["fpx-cli", "fpx", "fpx-workers", "fpx-macros", "xtask"]

[workspace.package]
authors = ["Fiberplane <[email protected]>"]
Expand Down
80 changes: 80 additions & 0 deletions fpx-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[package]
name = "fpx-cli"
version = { workspace = true }
edition = "2021"
authors = { workspace = true }
license = { workspace = true }
repository = { workspace = true }

[features]
embed-studio = [] # When enabled it will embed Studio from frontend/dist

[dependencies]
anyhow = { workspace = true }
async-trait = { version = "0.1" }
axum = { workspace = true, default-features = false, features = [
"http1",
"query",
"tokio",
"tracing",
"ws",
] }
bytes = { version = "1.6" }
clap = { workspace = true, features = ["derive", "env"] }
fpx = { version = "0.1.0", path = "../fpx", features = [
"libsql",
"fpx_client",
] }
fpx-macros = { version = "0.1.0", path = "../fpx-macros" }
futures-util = { version = "0.3" }
hex = { version = "0.4" }
http = { version = "1.1" }
http-body-util = { version = "0.1" }
include_dir = { version = "0.7.3" }
libsql = { version = "0.6", default-features = false, features = [
"core",
"serde",
] }
once_cell = { version = "1.19" }
opentelemetry = { version = "0.27" }
opentelemetry_sdk = { version = "0.27", features = ["rt-tokio"] }
opentelemetry-otlp = { version = "0.27", features = [
"http-json",
"reqwest-client",
"reqwest-rustls-webpki-roots",
] }
opentelemetry-proto = { version = "0.27", features = [
"gen-tonic-messages",
"with-serde",
"with-schemars",
] }
prost = { version = "0.13" }
rand = { version = "0.8.5" }
schemars = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_with = { version = "3.8.1" }
strum = { version = "0.26", features = ["derive"] }
thiserror = { version = "2.0" }
time = { version = "0.3.17", features = ["serde-human-readable"] }
tokio = { version = "1.40", features = ["rt-multi-thread", "signal", "fs"] }
tokio-tungstenite = { version = "0.21", features = [
"rustls-tls-webpki-roots",
] } # This should be kept the same as whatever Axum has
toml = { version = "0.8" }
tonic = { version = "0.12" }
tower = { version = "0.4" }
tracing = { version = "0.1" }
tracing-opentelemetry = { version = "0.28" }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
url = { version = "2.5" }

[target.'cfg(windows)'.dependencies]
libsql = { version = "0.6", default-features = false, features = [
"core",
"serde",
"replication",
] }

[dev-dependencies]
test-log = { version = "0.2", default-features = false, features = ["trace"] }
55 changes: 55 additions & 0 deletions fpx-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# fpx

The fpx tool is a command line tool to launch a local HTTP or gRPC OTEL
ingestion endpoint. It also includes a CLI client to interact with some of the
Rest and web-socket endpoints.

NOTE: Currently only a in-memory storage is supported.

## Usage

First, make sure you have Rust installed on your machine. You can install Rust
using [rustup](https://rustup.rs/) or take a look at the
[official instructions](https://www.rust-lang.org/tools/install).

Then run the following command to execute the local dev server:

```
cargo run -- dev
```

See `Commands` for more information.

## Commands

The fpx binary is primarily used to start a local dev server, but it is also
possible to run some other commands.

For ease of use, the `fpx` cargo alias has been added, meaning you can run
`cargo fpx` in any directory in this repository and compile and then invoke
`fpx`.

### `fpx dev`

Starts the local dev server.

Use `-e` or `--enable-tracing` to send otlp payloads to `--otlp-endpoint`. Note
that this should not be used to send traces to itself, as that will create an
infinite loop.

### `fpx client`

Invokes endpoints on a fpx server.

This command can also send traces to a otel endpoint. NOTE: there are some known
issues where it doesn't seem to work properly.

Examples:

```
# Fetch all traces
fpx client traces list
# Fetch a specific span
fpx client spans get aa aa
```
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::api::client::ApiClient;
use anyhow::Result;
use clap::Subcommand;
use fpx::api::client::ApiClient;
use std::io::stdout;
use url::Url;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::api::client::ApiClient;
use anyhow::Result;
use clap::Subcommand;
use fpx::api::client::ApiClient;
use std::io::stdout;
use url::Url;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{Context, Result};
use fpx_lib::api::models::FPX_WEBSOCKET_ID_HEADER;
use fpx::api::models::FPX_WEBSOCKET_ID_HEADER;
use futures_util::{SinkExt, StreamExt};
use std::sync::Arc;
use tokio::sync::Mutex;
Expand Down
2 changes: 1 addition & 1 deletion fpx/src/commands/dev.rs → fpx-cli/src/commands/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::events::InMemoryEvents;
use crate::grpc::GrpcService;
use crate::initialize_fpx_dir;
use anyhow::{Context, Result};
use fpx_lib::{api, service};
use fpx::{api, service};
use opentelemetry_proto::tonic::collector::trace::v1::trace_service_server::TraceServiceServer;
use std::future::IntoFuture;
use std::path::PathBuf;
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5a16788

Please sign in to comment.