tree: 204fe312f087131e4914e0e51c7c3f8403994b6c [path history] [tgz]
  1. source_generator_test_files/
  2. cpp.go
  3. dart.go
  4. dep.go
  5. dep_test.go
  6. go.go
  7. ident.go
  8. ident_test.go
  9. json.go
  10. json_test.go
  11. README.md
  12. rust.go
  13. simple.go
  14. source_generator_test.go
  15. source_outputter.go
  16. source_outputter_test.go
  17. utils.go
  18. utils_test.go
  19. writer.go
src/bin/config_parser/src/source_generator/README.md

Cobalt Registry Source Generator

This code generates source files for C++, Dart, and Rust to facilitate interacting with the Cobalt API in those languages.

What this generator outputs

For Cobalt 0.1 clients, it writes out constants for all customer ids, project ids, metric ids, and report ids for the selected config. It will output these constants with names that match the language's standard global constant naming convention. (e.g. C++ uses kCamelCase, and rust uses UPPER_SNAKE_CASE)

For Cobalt 1.0 clients, the generator also generates enums for all of the event_codes. If a metric_definition looked like the following:

- id: 1
  metric_name: "A Metric"
  metric_dimensions:
    - dimension: "A Dimension"
      event_codes:
        0: "An Event"
        1: "Another Event"
        2: "A Third Event"

It would generate enums like the following in C++:

enum AMetricMetricDimensionADimension {
  AnEvent = 0,
  AnotherEvent = 1,
  AThirdEvent = 2,
}

And the following in Rust:

pub enum AMetricMetricDimensionADimension {
  AnEvent = 0,
  AnotherEvent = 1,
  AThirdEvent = 2,
}

And the following in Dart:

class AMetricMetricDimensionADimension {
  static const int AnEvent = 0;
  static const int AnotherEvent = 1;
  static const int AThirdEvent = 2;
}

For more examples of what would be outputted, see the files under the source_generator_test_files directory.