|
3 | 3 | [](https://crates.io/crates/code0-flow) |
4 | 4 | [](https://docs.rs/code0-flow) |
5 | 5 |
|
6 | | -code0-flow is a Rust library developed by Code0 for managing flows within the FlowQueue and FlowStore. This libray is only for the internal usage of the execution block services (Aquila, Draco & Tarurs) and is not intendet to get used elsewhere. |
| 6 | +Internal Rust library for CodeZero execution services (Aquila, Draco, Taurus). It manages flow definitions, config helpers, and health checks. |
7 | 7 |
|
8 | 8 | ## Features |
9 | 9 |
|
10 | | -- `flow_definition` update the Adapter & Runtime definitions |
11 | | -- `flow_config` base configuration for each service |
12 | | -- `flow_health` provide health checks including NATS connectivity for readiness probes |
| 10 | +- `flow_definition` read flow definitions from a filesystem layout (per-feature folders with `data_type/`, `flow_type/`, `runtime_definition/` JSONs) with optional feature/version filtering |
| 11 | +- `flow_service` push definitions to Aquila via gRPC (depends on `flow_definition`) |
| 12 | +- `flow_config` env helpers and `.env` loading |
| 13 | +- `flow_health` tonic health service with NATS readiness |
13 | 14 |
|
14 | | -## FlowStore |
15 | | - |
16 | | -### Keys |
17 | | - |
18 | | -The key in the FlowStore in a Store will always have the pattern: |
19 | | - |
20 | | -`flow_id::project_id::flow_type_identifier::<any_flow_type_specific_data>` |
21 | | - |
22 | | -E.g. for REST: |
23 | | - |
24 | | -`1::1::REST::test.code0.tech::GET` |
25 | | - |
26 | | -This would be a REST Flow identifier |
27 | | - |
28 | | -## FlowDefinition |
29 | | - |
30 | | -```rust |
31 | | -// Define FlowType |
32 | | -let flow_type = FlowType { |
33 | | - identifier: String::from("REST"), |
34 | | - settings: vec![], |
35 | | - input_type_identifier: Some(String::from("HTTP_REQUEST_OBJECT")), |
36 | | - return_type_identifier: Some(String::from("HTTP_RESPONSE_OBJECT")), |
37 | | - editable: true, |
38 | | - name: vec![Translation { |
39 | | - code: String::from("en-US"), |
40 | | - content: String::from("Rest Endpoint"), |
41 | | - }], |
42 | | - description: vec![Translation { |
43 | | - code: String::from("en-US"), |
44 | | - content: String::from("A REST API is a web service that lets clients interact with data on a server using standard HTTP methods like GET, POST, PUT, and DELETE, usually returning results in JSON format."), |
45 | | - }], |
46 | | -}; |
47 | | - |
48 | | -// Define DataTypes |
49 | | -let data_type = DataType { |
50 | | - variant: 5, |
51 | | - name: vec![Translation { |
52 | | - code: String::from("en-US"), |
53 | | - content: String::from("HTTP Headers"), |
54 | | - }], |
55 | | - identifier: String::from("HTTP_HEADER_MAP"), |
56 | | - input_types: vec![], |
57 | | - return_type: None, |
58 | | - parent_type_identifier: Some(String::from("ARRAY")), |
59 | | - rules: vec![DataTypeRule { |
60 | | - config: Some(Config::ContainsType(DataTypeContainsTypeRuleConfig { |
61 | | - data_type_identifier: String::from("HTTP_HEADER_ENTRY"), |
62 | | - })), |
63 | | - }], |
64 | | -} |
65 | | - |
66 | | -// Send to get updated in Sagittarius |
67 | | -let update_client = code0_flow::flow_definition::FlowUpdateService::from_url(aquila_url) |
68 | | - .with_data_types(vec![data_type]) |
69 | | - .with_flow_types(vec![flow_type]); |
70 | | - |
71 | | -// Response --> true if successfull |
72 | | -update_client.send().await; |
73 | | -``` |
74 | | - |
75 | | -## FlowHealth |
76 | | - |
77 | | -```rust |
78 | | -use code0_flow::flow_health::HealthService; |
79 | | -use tonic_health::pb::health_server::HealthServer; |
80 | | - |
81 | | -// Create health service with NATS URL |
82 | | -let health_service = HealthService::new("nats://localhost:4222".to_string()); |
83 | | - |
84 | | -// Use with tonic gRPC server |
85 | | -let health_server = HealthServer::new(health_service); |
86 | | - |
87 | | -// The service provides: |
88 | | -// - "liveness" check: Always returns Serving (application is running) |
89 | | -// - "readiness" check: Returns Serving only if NATS connection is healthy |
90 | | -``` |
0 commit comments