Automatic push from FunctionsAPI
This commit is contained in:
parent
411ca5e39c
commit
098023aba1
3535
Cargo.lock
generated
Normal file
3535
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
Cargo.toml
Normal file
11
Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[package]
|
||||||
|
edition = "2024"
|
||||||
|
name = "web"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
fathom-function = { git = "ssh://git@github.com/fathom-io/pipeline-calculations.git", branch = "johnabell/ili-comparison" }
|
||||||
|
pipeline-application = { git = "ssh://git@github.com/fathom-io/pipeline-calculations.git", branch = "johnabell/ili-comparison" }
|
||||||
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
|
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] }
|
||||||
|
uuid = { version = "1" }
|
||||||
45
README.md
45
README.md
@ -1,2 +1,45 @@
|
|||||||
# 6ff5eb62447c4e4eb321dc2fc29ae95c
|
# Updates the pipeline facility geolocations
|
||||||
|
|
||||||
|
A function that updates the pipeline facilities with their geolocation based on
|
||||||
|
the pipeline route. Fails if there is no pipeline route.
|
||||||
|
|
||||||
|
## Input
|
||||||
|
|
||||||
|
### Arguments
|
||||||
|
|
||||||
|
- `pipeline_id`: a `string` which should be a valid uuid for a pipeline.
|
||||||
|
|
||||||
|
### Environment
|
||||||
|
|
||||||
|
- `ORG_ID`: the organization id
|
||||||
|
- `PROJECT_ID`: the id of the data project where the pipeline data is found
|
||||||
|
- `ENV`: the environment of the platform e.g. `dev` or `stg` etc.
|
||||||
|
|
||||||
|
## Creating the function on the platform
|
||||||
|
|
||||||
|
To create this function on the platform using the `cli` set up the port forwarding as shown in README.
|
||||||
|
|
||||||
|
Then run the following command to create the function.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run functions create \
|
||||||
|
-f functions/facility_locations \
|
||||||
|
-n facilitylocations \
|
||||||
|
-d "Update the facility locations based on the pipeline route and log distance" \
|
||||||
|
-i pipeline_id=string
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing the function locally
|
||||||
|
|
||||||
|
You can run and test the function locally by running
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can check it work with `curl` as follows
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST localhost:8080 -v \
|
||||||
|
-d "\"{\\\"pipeline_id\\\": \\\"0195a527-f16b-7d83-b936-35bc2dd92f9d\\\"}\""
|
||||||
|
```
|
||||||
|
|||||||
24
src/main.rs
Normal file
24
src/main.rs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
use fathom_function::Context;
|
||||||
|
use pipeline_application::application::Application;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
#[fathom_function::function(default(
|
||||||
|
org_id = "2cbfe270-d195-48ad-aed1-24145924635c",
|
||||||
|
project_id = "6807aed617c4295ab4a6aa78"
|
||||||
|
))]
|
||||||
|
async fn pipeline_route(context: Context, input: Input) -> Result<String, String> {
|
||||||
|
for pipeline_id in input.pipeline_id {
|
||||||
|
Application::new(context.env, context.org_id, &context.project_id)
|
||||||
|
.unwrap()
|
||||||
|
.update_assets_with_geo_locations(pipeline_id)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
Ok("Success".to_owned())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct Input {
|
||||||
|
pipeline_id: Vec<Uuid>,
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user