Smart Core OS Protocol Definitions


License
MIT
Install
go get github.com/smart-core-os/sc-api/go

Documentation

Smart Core API

This repository contains the interface definitions for the base Smart Core functionality. Looking at the .proto files should give a better understanding of how to communicate between different services in a Smart core system.

In addition, this repository also holds the generated go dependencies necessary for working with these APIs, and a pom file for generating the published java dependencies. See readme files in the language folders for details of updating or publishing these dependencies.

Project Layout

Most of the source in this repository is generated by tooling based off of the files in protobuf. Here is a rundown of the different sub-modules

  • protobuf - The definitions for the Smart Core API, edit the API here
  • docs - Public documentation for the API
  • doc - Generated API reference
  • go - Generated Go API library
  • grpc-web - Generated grpc-web API library
  • java - Setup for generating and deploying the Java API library
  • node - Generated NodeJS package for the API

Proto Files

Trait definitions live in the protobuf/traits directory, one trait per file. See Traits for more details on trait naming patterns.

Common types live in the protobuf/types directory, all other proto files should live close to the root protobuf directory, but not in it. See protobuf/info as an example.

Proto Enums

Enums in proto files need a special shout out. Protobuf says that enums members have package level scope, that means that no two enum members in the same package (i.e. in all the traits) can share the same name. To avoid this we nest the enum inside the message that would be classed as the primary use for the enum.

Primary use is a subjective term and there might be some ambiguity as to where to put the enum. In practice this rarely happens, typically the primary resource for a trait is the primary user of the enum. If you're still unsure check the existing trait protos for examples. If no primary use is possible - maybe the enum is part of common code - then the enum members should be prefixed with the enum name.

Re-generating Code

Run ./generate-all.sh if you change anything in the protobuf directory to re-generate all the derived sources. This script only works in a shell environment like Linux or GitBash.