-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update guide and styles (#117)
- Loading branch information
Showing
28 changed files
with
2,074 additions
and
29,563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ vendor/ | |
.env | ||
stencil | ||
/config.yaml | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Avro | ||
|
||
We are in the process of actively improving Stencil documentation. This guide will be updated very soon. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# JSON | ||
|
||
We are in the process of actively improving Stencil documentation. This guide will be updated very soon. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Protobuf | ||
|
||
We are in the process of actively improving Stencil documentation. This guide will be updated very soon. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Concepts | ||
# Glossary | ||
|
||
This section describes the core elements of a schema registry. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Tabs from "@theme/Tabs"; | ||
import TabItem from "@theme/TabItem"; | ||
|
||
# Introduction | ||
|
||
This tour introduces you to Stencil schema registry. Along the way you will learn how to manage schemas, enforce rules, serialise and deserialise data using stencil clients. | ||
|
||
### Prerequisites | ||
|
||
This tour requires you to have Stencil CLI tool installed on your local machine. You can run `stencil version` to verify the installation. Please follow installation guide if you do not have it installed already. | ||
|
||
Stencil CLI and clients talks to Stencil server to publish and fetch schema. Please make sure you also have a stencil server running. You can also run server locally with `stencil server start` command. For more details check deployment guide. | ||
|
||
### Help | ||
|
||
At any time you can run the following commands. | ||
|
||
```bash | ||
# Check the installed version for stencil cli tool | ||
$ stencil version | ||
|
||
# See the help for a command | ||
$ stencil --help | ||
``` | ||
|
||
Help command can also be run on any sub command. | ||
|
||
```bash | ||
$ stencil schema --help | ||
``` | ||
|
||
Check the reference for stencil cli commands. | ||
|
||
```bash | ||
$ stencil reference | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
import Tabs from "@theme/Tabs"; | ||
import TabItem from "@theme/TabItem"; | ||
|
||
# Quickstart | ||
|
||
This quick start will explore how to use Stencil command line interface and client libraries inside your application code. As part of this quick start we will start stencil server, create schema and then use stencil clients to serialise and deserialise data using registered schemas. | ||
|
||
## Prerequisites | ||
|
||
- [Docker](installation#using-docker-image) or a [local installation](installation#binary-cross-platform) of the Stencil binary. | ||
- A development environment applicable to one of the languages in this quick start (currently Go, Java, and JavaScript). | ||
- Postgres database and [protoc](https://github.com/protocolbuffers/protobuf#protocol-compiler-installation) if your schema format is protobuf. | ||
|
||
## Step 1: Start server | ||
|
||
<Tabs> | ||
<TabItem value="executable" label="Executable" default> | ||
|
||
Run stencil server locally using installed stencil binary. | ||
Note: Below command assumes `stencil_dev` db present in your postgres instance. | ||
|
||
```bash | ||
$ export DB_CONNECTIONSTRING=postgres://postgres@localhost:5432/stencil_dev?sslmode=disable | ||
|
||
# Run database migrations | ||
$ stencil server migrate | ||
|
||
# Stencil server | ||
$ stencil server start | ||
|
||
# Check if server running | ||
$ curl -X GET http://localhost:8080/ping | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="docker" label="Docker"> | ||
|
||
Run stencil server locally using docker | ||
Note: Below command assumes `stencil_dev` db present in your postgres instance. | ||
|
||
```bash | ||
# Run database migrations | ||
$ docker run -e PORT=8000 -e DB_CONNECTIONSTRING=postgres://postgres@host.docker.internal:5432/stencil_dev?sslmode=disable -p 8000:8000 odpf/stencil server migrate | ||
|
||
# Stencil server at port 8000 | ||
$ docker run -e PORT=8000 -e DB_CONNECTIONSTRING=postgres://postgres@host.docker.internal:5432/stencil_dev?sslmode=disable -p 8000:8000 odpf/stencil server start | ||
|
||
# Check if server running | ||
$ curl -X GET http://localhost:8000/ping | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
## Step 2: Create schema | ||
|
||
<Tabs> | ||
<TabItem value="protobuf" label="Protobuf"> | ||
|
||
```bash | ||
$ mkdir example | ||
$ cd example | ||
|
||
# Create a sample proto schema. | ||
$ echo "syntax=\"proto3\"; | ||
package stencil; | ||
message One { | ||
int32 field_one = 1; | ||
}" > schema.proto | ||
|
||
# Create proto descriptor file | ||
$ protoc --descriptor_set_out=./schema.desc --include_imports ./**/*.proto | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="avro" label="Avro"> | ||
|
||
```bash | ||
$ mkdir example | ||
$ cd example | ||
|
||
# Create a sample avro schema. | ||
$ echo "{ | ||
\"type\" : \"record\", | ||
\"namespace\" : \"Tutorialspoint\", | ||
\"name\" : \"Employee\", | ||
\"fields\" : [ | ||
{ \"name\" : \"Name\" , \"type\" : \"string\" }, | ||
{ \"name\" : \"Age\" , \"type\" : \"int\" } | ||
] | ||
}" > schema.json | ||
|
||
``` | ||
|
||
</TabItem> | ||
<TabItem value="json" label="JSON"> | ||
|
||
```bash | ||
$ mkdir example | ||
$ cd example | ||
|
||
# Create example JSON schema file. | ||
$ echo "{ | ||
\"type\":\"object\", | ||
\"properties\":{ | ||
\"f1\":{ | ||
\"type\":\"string\" | ||
} | ||
}, | ||
\"additionalProperties\": false | ||
}" > schema.json | ||
|
||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
## Step 3: Upload to server | ||
|
||
<Tabs> | ||
<TabItem value="cli" label="CLI"> | ||
|
||
```bash | ||
# Create namespace named "quickstart" with backward compatibility enabled | ||
$ stencil namespace create -c COMPATIBILITY_BACKWARD -f FORMAT_PROTOBUF -d "For quickstart guide" --host http://localhost:8000 | ||
|
||
# List namespaces | ||
$ stencil namespace list | ||
|
||
# Upload generated schema proto descriptor file to server with schema name as `example` under `quickstart` namespace. | ||
$ stencil schema create example --namespace=quickstart –-filePath=schema.desc | ||
|
||
# Get list of schemas available in a namespace | ||
$ stencil schema list --host http://localhost:8000 | ||
|
||
# Get list of versions available for particular schema. These versions are auto generated. | ||
# Version numbers managed by stencil. | ||
$ stencil schema version example -n quickstart --host http://localhost:8000 | ||
|
||
# Download specific version of particular schema | ||
$ stencil schema get example --version 1 --host http://localhost:8000 | ||
|
||
# Download latest version of particular schema | ||
$ stencil schema get example -n quickstart --host http://localhost:8000 | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="api" label="API"> | ||
|
||
```bash | ||
# Create namespace named "quickstart" with backward compatibility enabled | ||
$ curl -X POST http://localhost:8000/v1beta1/namespaces -H 'Content-Type: application/json' -d '{"id": "quickstart", "format": "FORMAT_PROTOBUF", "compatibility": "COMPATIBILITY_BACKWARD", "description": "For quickstart guide"}' | ||
|
||
# List namespaces | ||
$ curl http://localhost:8000/v1beta1/namespaces | ||
|
||
# Upload generated schema proto descriptor file to server with schema name as `example` under `quickstart` namespace. | ||
$ curl -X POST http://localhost:8000/v1beta1/namespaces/quickstart/schemas/example --data-binary "@schema.desc" | ||
|
||
# Get list of schemas available in a namespace | ||
$ curl -X GET http://localhost:8000/v1beta1/namespaces/quickstart/schemas | ||
|
||
# Get list of versions available for particular schema. These versions are auto generated. | ||
# Version numbers managed by stencil. | ||
$ curl -X GET http://localhost:8000/v1beta1/namespaces/quickstart/schemas/example/versions | ||
|
||
# Download specific version of particular schema | ||
$ curl -X GET http://localhost:8000/v1beta1/namespaces/quickstart/schemas/example/versions/1 | ||
|
||
# Download latest version of particular schema | ||
$ curl -X GET http://localhost:8000/v1beta1/namespaces/quickstart/schemas/example; | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
## Step 4: Using client | ||
|
||
Let's use this API in our GO client | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"log" | ||
stencil "github.com/odpf/stencil/clients/go" | ||
) | ||
|
||
func main() { | ||
url := "http://localhost:8000/v1/namespaces/quickstart/descriptors/example/versions/latest" | ||
client, err := stencil.NewClient([]string{url}, stencil.Options{}) | ||
if err != nil { | ||
log.Fatal("Unable to create client", err) | ||
return | ||
} | ||
desc, err := client.GetDescriptor("stencil.One") | ||
// ... | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Manage namespaces | ||
|
||
We are in the process of actively improving Stencil documentation. This guide will be updated very soon. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Using clients |
Oops, something went wrong.