Packages
caffeine_lang
0.0.17
6.3.1
6.3.0
6.2.2
6.2.1
6.2.0
6.1.2
6.1.1
6.1.0
6.0.0
5.6.0
5.5.0
5.4.4
5.4.3
5.4.2
5.4.1
5.4.0
5.3.0
5.2.0
5.1.1
5.1.0
5.0.12
5.0.11
5.0.10
5.0.8
5.0.7
5.0.6
5.0.5
5.0.4
5.0.1
5.0.0
4.10.0
4.9.0
4.8.3
4.8.2
4.8.1
4.8.0
4.7.9
4.7.8
4.7.7
4.7.6
4.7.5
4.6.7
4.6.6
4.6.5
4.6.4
4.6.3
4.6.2
4.6.0
4.5.1
4.5.0
4.4.4
4.4.3
4.4.1
4.4.0
4.3.7
4.3.6
3.0.6
3.0.5
3.0.4
3.0.3
3.0.2
3.0.1
3.0.0
2.0.5
2.0.4
2.0.3
2.0.2
2.0.1
2.0.0
1.0.2
1.0.1
0.1.0
0.0.24
0.0.23
0.0.22
0.0.21
0.0.20
0.0.19
0.0.18
0.0.17
0.0.16
0.0.15
0.0.14
0.0.13
0.0.12
0.0.11
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.2
0.0.1
A compiler for generating reliability artifacts from service expectation definitions.
Current section
Files
Jump to
Current section
Files
caffeine_lang
README.md
README.md
# caffeine
[](https://github.com/Brickell-Research/caffeine_lang/actions/workflows/test.yml)
[](https://www.gnu.org/licenses/gpl-3.0)
[](https://gleam.run/)
<div align="center">
<img src="images/caffeine_icon.png" alt="Caffeine Icon" width="250" height="250">
</div>
Caffeine is a compiler for generating reliability artifacts from service expectation definitions.
***
## Installation
**We recommend using within a CICD pipeline.**
Within a GitHub Actions workflow, you can use the following action:
```bash
- name: Caffeine Language GitHub Action
uses: Brickell-Research/caffeine_lang_github_action@vmain
```
[See the action in the Github Actions Marketplace](https://github.com/marketplace/actions/caffeine-language-action).
***
## Architecture & RFCs
For detailed architectural decisions and design proposals, see our [RFCs directory](rfcs/):
- [RFC 001: Extensible Architecture](rfcs/001_Extensible_Architecture.md) - Core architectural principles and design patterns
- [RFC 002: Caffeine Query Language](rfcs/002_Caffeine_Query_Language.md) - The Caffeine Query Language (CQL)
***
## Quick Start
Projects are structured as follows:
```
some_organization/
├── platform/
│ └── reliable_service.yaml
├── frontend/
│ └── unreliable_service.yaml
├── specifications/
├── basic_types.yaml
├── query_template_types.yaml
├── services.yaml
└── sli_types.yaml
```
Here we have two _types_ of files, `instantiation` and `specification`.
### Instantiation
**Instantiation**: define the SLO(s) for a service. Each service defines one or more SLOs in a `yaml` file with the name of the file being the name of the service and the parent directory being the name of the owning team.
As an example, `platform/reliable_service.yaml`:
```yaml
slos:
- sli_type: "http_requests_success_rate"
typed_instatiation_of_query_templatized_variables:
"peer_hostname": "api.google.com"
"environment": "production"
"http_status_codes": "[200, 201, 202, 204]"
threshold: 99.0
window_in_days: 90
```
Here `threshold` and `window_in_days` are always required, `sli_type` refers to an sli type from the specification and `typed_instatiation_of_query_templatized_variables` is a series of mappings between expected attributes for the sli type and their values.
### Specification
**Specification**: define the templates available for defining SLI(s).
There are four types of specifications to define.
**(1) basic types:** a mapping of attribute names to the expected type. These are names of expected parameters used by other parts of the specification.
Example:
```yaml
basic_types:
- attribute_name: peer_hostname
attribute_type: String
- attribute_name: environment
attribute_type: String
- attribute_name: http_status_codes
attribute_type: List(Integer)
```
**(2) query template types:** a definition of a query template type. The query is a CQL expression and the specification of query templates is a list of basic type names that are expected to be used in the query.
Example:
```yaml
query_template_types:
- name: "valid_over_total"
specification_of_query_templates: ["peer_hostname", "environment"]
query: "numerator / denominator"
```
**(3) services:** a mapping of service names to supported sli types.
Example:
```yaml
services:
- name: reliable_service
sli_types:
- http_requests_success_rate
```
**(4) sli types:** a definition of an SLI type that combines a query template type with specific query instantiations and the required templatized variables.
Example:
```yaml
types:
- name: http_requests_success_rate
query_template_type: valid_over_total
typed_instatiation_of_query_templates:
numerator: "sum.http_requests.hits{peer.hostname:$$peer_hostname$$ AND env:$$environment$$ AND http.status_code IN $$http_status_codes$$}.as_count()"
denominator: "sum.http_requests.hits{peer.hostname:$$peer_hostname$$ AND env:$$environment$$}.as_count()"
specification_of_query_templatized_variables:
- peer_hostname
- environment
- http_status_codes
```
Once all of this is defined, execute the compiler as follows:
```gleam
compiler.compile("some_organization/specifications", "some_organization", "some_output_dir")
```
***
## License
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.