Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Clivern committed Jul 26, 2021
1 parent 8ed0fb9 commit 56321c3
Show file tree
Hide file tree
Showing 25 changed files with 154 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ checksum:
name_template: checksums.txt
snapshot:
name_template: "{{ .Tag }}-next"
project_name: walnut
project_name: drifter
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.16.6

ARG WALNUT_VERSION=0.1.0
ARG DRIFTER_VERSION=0.1.0

ENV GO111MODULE=on

Expand All @@ -11,7 +11,7 @@ RUN apt-get update

WORKDIR /app

RUN curl -sL https://github.com/Clivern/Walnut/releases/download/v${WALNUT_VERSION}/walrus_${WALNUT_VERSION}_Linux_x86_64.tar.gz | tar xz
RUN curl -sL https://github.com/Clivern/Drifter/releases/download/v${DRIFTER_VERSION}/walrus_${DRIFTER_VERSION}_Linux_x86_64.tar.gz | tar xz
RUN rm LICENSE
RUN rm README.md

Expand All @@ -22,6 +22,6 @@ EXPOSE 8000
VOLUME /app/configs
VOLUME /app/var

RUN ./walnut version
RUN ./drifter version

CMD ["./walnut", "server", "-c", "/app/configs/config.dist.yml"]
CMD ["./drifter", "server", "-c", "/app/configs/config.dist.yml"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pkgs = ./...

help: Makefile
@echo
@echo " Choose a command run in Walnut:"
@echo " Choose a command run in Drifter:"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo
Expand Down Expand Up @@ -121,7 +121,7 @@ package:
.PHONY: run
run:
@echo ">> ============= Run API Server ============= <<"
$(GO) run walnut.go server -c config.dist.yml
$(GO) run drifter.go server -c config.dist.yml


## ci: Run all CI tests.
Expand Down
88 changes: 44 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<p align="center">
<img src="/assets/logo.png?v=0.1.0" width="240" />
<h3 align="center">Walnut</h3>
<h3 align="center">Drifter</h3>
<p align="center">A Lightweight Cloud Native API Gateway.</p>
<p align="center">
<a href="https://github.com/Clivern/Walnut/actions/workflows/build.yml">
<img src="https://github.com/Clivern/Walnut/actions/workflows/build.yml/badge.svg">
<a href="https://github.com/Clivern/Drifter/actions/workflows/build.yml">
<img src="https://github.com/Clivern/Drifter/actions/workflows/build.yml/badge.svg">
</a>
<a href="https://github.com/Clivern/Walnut/actions">
<img src="https://github.com/Clivern/Walnut/workflows/Release/badge.svg">
<a href="https://github.com/Clivern/Drifter/actions">
<img src="https://github.com/Clivern/Drifter/workflows/Release/badge.svg">
</a>
<a href="https://github.com/Clivern/Walnut/releases">
<a href="https://github.com/Clivern/Drifter/releases">
<img src="https://img.shields.io/badge/Version-0.1.0-red.svg">
</a>
<a href="https://goreportcard.com/report/github.com/Clivern/Walnut">
<img src="https://goreportcard.com/badge/github.com/Clivern/Walnut?v=0.1.0">
<a href="https://goreportcard.com/report/github.com/Clivern/Drifter">
<img src="https://goreportcard.com/badge/github.com/Clivern/Drifter?v=0.1.0">
</a>
<a href="https://godoc.org/github.com/clivern/walnut">
<img src="https://godoc.org/github.com/clivern/walnut?status.svg">
<a href="https://godoc.org/github.com/clivern/drifter">
<img src="https://godoc.org/github.com/clivern/drifter?status.svg">
</a>
<a href="https://github.com/Clivern/Walnut/blob/master/LICENSE">
<a href="https://github.com/Clivern/Drifter/blob/master/LICENSE">
<img src="https://img.shields.io/badge/LICENSE-MIT-orange.svg">
</a>
</p>
</p>
<br/>

Walnut is Cloud Native API Gateway that control who accesses your API whether from customer or other internal services. It also collect metrics about service calls count, latency, success rate and much more. here is some of the key features:
Drifter is Cloud Native API Gateway that control who accesses your API whether from customer or other internal services. It also collect metrics about service calls count, latency, success rate and much more. here is some of the key features:

- Manage service to service Authentication and Authorization.
- Manage user to service Authentication and Authorization.
Expand All @@ -44,12 +44,12 @@ Walnut is Cloud Native API Gateway that control who accesses your API whether fr

#### Linux Deployment

Download [the latest walnut binary](https://github.com/Clivern/Walnut/releases). Make it executable from everywhere.
Download [the latest drifter binary](https://github.com/Clivern/Drifter/releases). Make it executable from everywhere.

```zsh
$ export WALNUT_LATEST_VERSION=$(curl --silent "https://api.github.com/repos/Clivern/Walnut/releases/latest" | jq '.tag_name' | sed -E 's/.*"([^"]+)".*/\1/' | tr -d v)
$ export DRIFTER_LATEST_VERSION=$(curl --silent "https://api.github.com/repos/Clivern/Drifter/releases/latest" | jq '.tag_name' | sed -E 's/.*"([^"]+)".*/\1/' | tr -d v)

$ curl -sL https://github.com/Clivern/Walnut/releases/download/v{$WALNUT_LATEST_VERSION}/walnut_{$WALNUT_LATEST_VERSION}_Linux_x86_64.tar.gz | tar xz
$ curl -sL https://github.com/Clivern/Drifter/releases/download/v{$DRIFTER_LATEST_VERSION}/drifter_{$DRIFTER_LATEST_VERSION}_Linux_x86_64.tar.gz | tar xz
```

Then install `etcd` cluster or a single node! please [refer to etcd docs](https://etcd.io/docs/v3.5/) or bin directory inside this repository.
Expand All @@ -60,88 +60,88 @@ Create the configs file `config.yml` from `config.dist.yml`. Something like the
# App configs
app:
# App name
name: ${WALNUT_APP_NAME:-walnut}
name: ${DRIFTER_APP_NAME:-drifter}
# Env mode (dev or prod)
mode: ${WALNUT_APP_MODE:-dev}
mode: ${DRIFTER_APP_MODE:-dev}
# HTTP port
port: ${WALNUT_API_PORT:-8000}
port: ${DRIFTER_API_PORT:-8000}
# Hostname
hostname: ${WALNUT_API_HOSTNAME:-127.0.0.1}
hostname: ${DRIFTER_API_HOSTNAME:-127.0.0.1}
# TLS configs
tls:
status: ${WALNUT_API_TLS_STATUS:-off}
pemPath: ${WALNUT_API_TLS_PEMPATH:-cert/server.pem}
keyPath: ${WALNUT_API_TLS_KEYPATH:-cert/server.key}
status: ${DRIFTER_API_TLS_STATUS:-off}
pemPath: ${DRIFTER_API_TLS_PEMPATH:-cert/server.pem}
keyPath: ${DRIFTER_API_TLS_KEYPATH:-cert/server.key}

# API Configs
api:
key: ${WALNUT_API_KEY:-6c68b836-6f8e-465e-b59f-89c1db53afca}
key: ${DRIFTER_API_KEY:-6c68b836-6f8e-465e-b59f-89c1db53afca}

# Async Workers
workers:
# Queue max capacity
buffer: ${WALNUT_WORKERS_CHAN_CAPACITY:-5000}
buffer: ${DRIFTER_WORKERS_CHAN_CAPACITY:-5000}
# Number of concurrent workers
count: ${WALNUT_WORKERS_COUNT:-4}
count: ${DRIFTER_WORKERS_COUNT:-4}

# Runtime, Requests/Response and Walnut Metrics
# Runtime, Requests/Response and Drifter Metrics
metrics:
prometheus:
# Route for the metrics endpoint
endpoint: ${WALNUT_METRICS_PROM_ENDPOINT:-/metrics}
endpoint: ${DRIFTER_METRICS_PROM_ENDPOINT:-/metrics}

# Components Configs
component:
# Tracing Component
tracing:
# Status on or off
status: ${WALNUT_TRACING_STATUS:-on}
status: ${DRIFTER_TRACING_STATUS:-on}
# Tracing driver, jaeger supported so far
driver: ${WALNUT_TRACING_DRIVER:-jaeger}
driver: ${DRIFTER_TRACING_DRIVER:-jaeger}
# Tracing backend URL
collectorEndpoint: ${WALNUT_TRACING_ENDPOINT:-http://jaeger.local:14268/api/traces}
collectorEndpoint: ${DRIFTER_TRACING_ENDPOINT:-http://jaeger.local:14268/api/traces}
# Batch Size
queueSize: ${WALNUT_TRACING_QUEUE_SIZE:-20}
queueSize: ${DRIFTER_TRACING_QUEUE_SIZE:-20}

# Profiler Component
profiler:
# Profiler Status
status: ${WALNUT_PROFILER_STATUS:-on}
status: ${DRIFTER_PROFILER_STATUS:-on}
# Profiler Driver
driver: ${WALNUT_PROFILER_DRIVER:-log}
driver: ${DRIFTER_PROFILER_DRIVER:-log}

# Log configs
log:
# Log level, it can be debug, info, warn, error, panic, fatal
level: ${WALNUT_LOG_LEVEL:-info}
# Output can be stdout or abs path to log file /var/logs/walnut.log
output: ${WALNUT_LOG_OUTPUT:-stdout}
level: ${DRIFTER_LOG_LEVEL:-info}
# Output can be stdout or abs path to log file /var/logs/drifter.log
output: ${DRIFTER_LOG_OUTPUT:-stdout}
# Format can be json
format: ${WALNUT_LOG_FORMAT:-json}
format: ${DRIFTER_LOG_FORMAT:-json}
```
The run the `walnut` with `systemd`
The run the `drifter` with `systemd`

```zsh
$ walnut server -c /path/to/config.yml
$ drifter server -c /path/to/config.yml
```


## Versioning

For transparency into our release cycle and in striving to maintain backward compatibility, Walnut is maintained under the [Semantic Versioning guidelines](https://semver.org/) and release process is predictable and business-friendly.
For transparency into our release cycle and in striving to maintain backward compatibility, Drifter is maintained under the [Semantic Versioning guidelines](https://semver.org/) and release process is predictable and business-friendly.

See the [Releases section of our GitHub project](https://github.com/clivern/walnut/releases) for changelogs for each release version of Walnut. It contains summaries of the most noteworthy changes made in each release.
See the [Releases section of our GitHub project](https://github.com/clivern/drifter/releases) for changelogs for each release version of Drifter. It contains summaries of the most noteworthy changes made in each release.


## Bug tracker

If you have any suggestions, bug reports, or annoyances please report them to our issue tracker at https://github.com/clivern/walnut/issues
If you have any suggestions, bug reports, or annoyances please report them to our issue tracker at https://github.com/clivern/drifter/issues


## Security Issues

If you discover a security vulnerability within Walnut, please send an email to [[email protected]](mailto:[email protected])
If you discover a security vulnerability within Drifter, please send an email to [[email protected]](mailto:[email protected])


## Contributing
Expand All @@ -153,4 +153,4 @@ We are an open source, community-driven project so please feel free to join us.

© 2021, Clivern. Released under [MIT License](https://opensource.org/licenses/mit-license.php).

**Walnut** is authored and maintained by [@clivern](http://github.com/clivern).
**Drifter** is authored and maintained by [@clivern](http://github.com/clivern).
4 changes: 2 additions & 2 deletions bin/release.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Fetch latest version
export LATEST_VERSION=$(curl --silent "https://api.github.com/repos/clivern/walnut/releases/latest" | jq '.tag_name' | sed -E 's/.*"([^"]+)".*/\1/')
export LATEST_VERSION=$(curl --silent "https://api.github.com/repos/clivern/drifter/releases/latest" | jq '.tag_name' | sed -E 's/.*"([^"]+)".*/\1/')

# Update go checksum database (sum.golang.org) immediately after release
curl --silent https://sum.golang.org/lookup/github.com/clivern/walnut@{$LATEST_VERSION}
curl --silent https://sum.golang.org/lookup/github.com/clivern/drifter@{$LATEST_VERSION}
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
var config string

var rootCmd = &cobra.Command{
Use: "walnut",
Use: "drifter",
Short: `🐺 A Lightweight Cloud Native API Gateway
If you have any suggestions, bug reports, or annoyances please report
them to our issue tracker at <https://github.com/clivern/walnut/issues>`,
them to our issue tracker at <https://github.com/clivern/drifter/issues>`,
}

// Execute runs cmd tool
Expand Down
10 changes: 5 additions & 5 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"strings"
"time"

"github.com/clivern/walnut/core/component"
"github.com/clivern/walnut/core/controller"
"github.com/clivern/walnut/core/module"
"github.com/clivern/drifter/core/component"
"github.com/clivern/drifter/core/controller"
"github.com/clivern/drifter/core/module"

"github.com/drone/envsubst"
"github.com/labstack/echo-contrib/prometheus"
Expand All @@ -31,7 +31,7 @@ import (

var serverCmd = &cobra.Command{
Use: "server",
Short: "Start walnut server",
Short: "Start drifter server",
Run: func(cmd *cobra.Command, args []string) {
configUnparsed, err := ioutil.ReadFile(config)

Expand Down Expand Up @@ -145,7 +145,7 @@ var serverCmd = &cobra.Command{

e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
cc := &controller.WalnutContext{Context: c}
cc := &controller.DrifterContext{Context: c}
return next(cc)
}
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var versionCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(
fmt.Sprintf(
`Current Walnut Version %v Commit %v, Built @%v By %v.`,
`Current Drifter Version %v Commit %v, Built @%v By %v.`,
Version,
Commit,
Date,
Expand Down
36 changes: 18 additions & 18 deletions config.dist.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# App configs
app:
# App name
name: ${WALNUT_APP_NAME:-walnut}
name: ${DRIFTER_APP_NAME:-drifter}
# Env mode (dev or prod)
mode: ${WALNUT_APP_MODE:-dev}
mode: ${DRIFTER_APP_MODE:-dev}
# HTTP port
port: ${WALNUT_API_PORT:-8000}
port: ${DRIFTER_API_PORT:-8000}
# Hostname
hostname: ${WALNUT_API_HOSTNAME:-127.0.0.1}
hostname: ${DRIFTER_API_HOSTNAME:-127.0.0.1}
# TLS configs
tls:
status: ${WALNUT_API_TLS_STATUS:-off}
crt_path: ${WALNUT_API_TLS_PEMPATH:-cert/server.crt}
key_path: ${WALNUT_API_TLS_KEYPATH:-cert/server.key}
status: ${DRIFTER_API_TLS_STATUS:-off}
crt_path: ${DRIFTER_API_TLS_PEMPATH:-cert/server.crt}
key_path: ${DRIFTER_API_TLS_KEYPATH:-cert/server.key}

# Global timeout
timeout: ${WALNUT_API_TIMEOUT:-50}
timeout: ${DRIFTER_API_TIMEOUT:-50}

# API Configs
api:
key: ${WALNUT_API_KEY:-6c68b836-6f8e-465e-b59f-89c1db53afca}
key: ${DRIFTER_API_KEY:-6c68b836-6f8e-465e-b59f-89c1db53afca}

# Runtime, Requests/Response and Walnut Metrics
# Runtime, Requests/Response and Drifter Metrics
metrics:
prometheus:
# Route for the metrics endpoint
endpoint: ${WALNUT_METRICS_PROM_ENDPOINT:-/_metrics}
endpoint: ${DRIFTER_METRICS_PROM_ENDPOINT:-/_metrics}

# Application Database
database:
Expand All @@ -36,7 +36,7 @@ app:
# Database Port
port: ${BEETLE_DATABASE_MYSQL_PORT:-3306}
# Database Name
name: ${BEETLE_DATABASE_MYSQL_DATABASE:-walnut.db}
name: ${BEETLE_DATABASE_MYSQL_DATABASE:-drifter.db}
# Database Username
username: ${BEETLE_DATABASE_MYSQL_USERNAME:-root}
# Database Password
Expand All @@ -47,7 +47,7 @@ app:
- name: orders
active: true
proxy:
listen_path: "/orders/v2/*path"
listen_path: "/orders/v2/*"
upstreams:
balancing: roundrobin
targets:
Expand All @@ -58,7 +58,7 @@ app:
status: off
methods:
-
uuid: 6c68b836-6f8e-465e-b59f-89c1db53afca
id: 1
rate_limit:
status: off

Expand All @@ -68,8 +68,8 @@ app:
# Log configs
log:
# Log level, it can be debug, info, warn, error, panic, fatal
level: ${WALNUT_LOG_LEVEL:-info}
# Output can be stdout or abs path to log file /var/logs/walnut.log
output: ${WALNUT_LOG_OUTPUT:-stdout}
level: ${DRIFTER_LOG_LEVEL:-info}
# Output can be stdout or abs path to log file /var/logs/drifter.log
output: ${DRIFTER_LOG_OUTPUT:-stdout}
# Format can be json
format: ${WALNUT_LOG_FORMAT:-json}
format: ${DRIFTER_LOG_FORMAT:-json}
Loading

0 comments on commit 56321c3

Please sign in to comment.