<commit_before># Sidecar

[![GoReportCard Widget]][GoReportCard] [![Travis Widget]][Travis]

[GoReportCard]: https://goreportcard.com/report/github.com/amalgam8/sidecar
[GoReportCard Widget]: https://goreportcard.com/badge/github.com/amalgam8/sidecar
[Travis]: https://travis-ci.org/amalgam8/sidecar
[Travis Widget]: https://travis-ci.org/amalgam8/sidecar.svg?branch=master

A language agnostic sidecar for building microservice applications with
automatic service registration, and load-balancing.

An overview of the Amalgam8 project is available here: http://amalgam8.io/

## Architecture

![Sidecar architecture](https://github.com/amalgam8/sidecar/blob/master/sidecar.jpg)

Refer to the [amalgam8 overview](https://github.com/amalgam8/amalgam8.github.io/blob/master/overview.md#tenant-process) for details.

## Usage
A prebuild Docker iamge is available at Docker Hub. Install Docker 1.8 or 1.9 and run the following:

```docker pull amalgam8/a8-sidecar:0.1```

### Configuration options
Configuration options can be set through environment variables or command line flags. 

| Environment Key | Flag Name                   | Description | Default Value |
|:----------------|:----------------------------|:------------|:--------------|
| LOG_LEVEL | --log_level | Logging level (debug, info, warn, error, fatal, panic) | info |
| SERVICE | --service | service name to register with | |
| SERVICE_VERSION | --service_version | service version to register with (optional). Service is UNVERSIONED by default |  |
| ENDPOINT_HOST | --endpoint_host | service endpoint host name (optional). Defaults to the IP (e.g., container) where the sidecar is running |  |
| ENDPOINT_PORT | --endpoint_port | service endpoint port | |
| REGISTER | --register | enable automatic service registration and heartbeat |  |
| PROXY | --proxy | enable automatic service discovery and load balancing across services using NGINX |  |
| LOG | --log | enable logging of outgoing requests through proxy using FileBeat |  |
| SUPERVISE | --supervise | Enable monitoring of application process. If application dies, container is killed as well. This has to be the last flag. All arguments provided after this flag will considered as part of the application invocation |  |
| TENANT_ID | --tenant_id | service Proxy instance GUID |  |
| TENANT_TOKEN | --tenant_token | token for Service Proxy instance |  |
| TENANT_TTL | --tenant_ttl | tenant TTL for Registry | 1m0s |
| TENANT_HEARTBEAT | --tenant_heartbeat | tenant heartbeat interval to Registry |  |
| REGISTRY_URL | --registry_url | registry URL | 45s |
| REGISTRY_TOKEN | --registry_token | registry API token | |
| NGINX_PORT | --nginx_port | port for NGINX | 6379 |
| CONTROLLER_URL | --controller_url | controller URL |  |
| CONTROLLER_POLL | --controller_poll | interval for polling Controller | 15s |
| LOGSTASH_SERVER | --logstash_server | logstash target for nginx logs |  |
| KAFKA_USER | --kafka_user | kafka username |  |
| KAFKA_PASS | --kafka_pass | kafka password |  |
| KAFKA_TOKEN | --kafka_token | kafka token |  |
| KAFKA_ADMIN_URL | --kafka_admin_url | kafka admin URL |  |
| KAFKA_REST_URL | --kafka_rest_url | kafka REST URL |  |
| KAFKA_SASL | --kafka_sasl | use SASL/PLAIN authentication for kafka |  |
| KAFKA_BROKER | --kafka_broker [--kafka_broker option --kafka_broker option] | kafka brokers |  |
|  | --help, -h | show help | |
|  | --version, -v | print the version | |

## Build from source
The follow section describes options for building the sidecar from source. Instructions on using a prebuilt Docker image are available [here](https://github.com/amalgam8/sidecar#usage).

### Preprequisites
* Docker 1.8 or 1.9
* Go 1.6

### Clone

Clone the repository manually, or use `go get`:

```go get github.com/amalgam8/sidecar```

### Make targets
The following targets are available. Each may be run with `make <target>`.<commit_msg>small README fixes<commit_after># Sidecar

[![GoReportCard Widget]][GoReportCard] [![Travis Widget]][Travis]

[GoReportCard]: https://goreportcard.com/report/github.com/amalgam8/sidecar
[GoReportCard Widget]: https://goreportcard.com/badge/github.com/amalgam8/sidecar
[Travis]: https://travis-ci.org/amalgam8/sidecar
[Travis Widget]: https://travis-ci.org/amalgam8/sidecar.svg?branch=master

A language agnostic sidecar for building microservice applications with
automatic service registration, and load-balancing.

An overview of the Amalgam8 project is available here: http://amalgam8.io/

## Architecture

![Sidecar architecture](https://github.com/amalgam8/sidecar/blob/master/sidecar.jpg)

Refer to the [amalgam8 overview](https://github.com/amalgam8/amalgam8.github.io/blob/master/overview.md#tenant-process) for details.

## Usage
A prebuild Docker image is available at Docker Hub. Install Docker 1.8 or 1.9 and run the following:

```docker pull amalgam8/a8-sidecar:0.1```

### Configuration options
Configuration options can be set through environment variables or command line flags. 

| Environment Key | Flag Name                   | Description | Default Value |
|:----------------|:----------------------------|:------------|:--------------|
| LOG_LEVEL | --log_level | Logging level (debug, info, warn, error, fatal, panic) | info |
| SERVICE | --service | service name to register with | |
| SERVICE_VERSION | --service_version | service version to register with (optional). Service is UNVERSIONED by default |  |
| ENDPOINT_HOST | --endpoint_host | service endpoint host name (optional). Defaults to the IP (e.g., container) where the sidecar is running |  |
| ENDPOINT_PORT | --endpoint_port | service endpoint port | |
| REGISTER | --register | enable automatic service registration and heartbeat |  |
| PROXY | --proxy | enable automatic service discovery and load balancing across services using NGINX |  |
| LOG | --log | enable logging of outgoing requests through proxy using FileBeat |  |
| SUPERVISE | --supervise | Enable monitoring of application process. If application dies, container is killed as well. This has to be the last flag. All arguments provided after this flag will considered as part of the application invocation |  |
| TENANT_ID | --tenant_id | service Proxy instance GUID |  |
| TENANT_TOKEN | --tenant_token | token for Service Proxy instance |  |
| TENANT_TTL | --tenant_ttl | tenant TTL for Registry | 1m0s |
| TENANT_HEARTBEAT | --tenant_heartbeat | tenant heartbeat interval to Registry |  |
| REGISTRY_URL | --registry_url | registry URL | 45s |
| REGISTRY_TOKEN | --registry_token | registry API token | |
| NGINX_PORT | --nginx_port | port for NGINX | 6379 |
| CONTROLLER_URL | --controller_url | controller URL |  |
| CONTROLLER_POLL | --controller_poll | interval for polling Controller | 15s |
| LOGSTASH_SERVER | --logstash_server | logstash target for nginx logs |  |
| KAFKA_USER | --kafka_user | kafka username |  |
| KAFKA_PASS | --kafka_pass | kafka password |  |
| KAFKA_TOKEN | --kafka_token | kafka token |  |
| KAFKA_ADMIN_URL | --kafka_admin_url | kafka admin URL |  |
| KAFKA_REST_URL | --kafka_rest_url | kafka REST URL |  |
| KAFKA_SASL | --kafka_sasl | use SASL/PLAIN authentication for kafka |  |
| KAFKA_BROKER | --kafka_broker [--kafka_broker option --kafka_broker option] | kafka brokers |  |
|  | --help, -h | show help | |
|  | --version, -v | print the version | |

## Build from source
The following sections describe options for building the sidecar from source. Instructions on using a prebuilt Docker image are available [above](https://github.com/amalgam8/sidecar#usage).

### Preprequisites
* Docker 1.8 or 1.9
* Go 1.6

### Clone

Clone the repository manually, or use `go get`:

```go get github.com/amalgam8/sidecar```

### Make targets
The following targets are available. Each may be run with `make <target>`.
{'fraction_non_alphanumeric': 0.12601052226356987, 'fraction_numerical': 0.009239060695495958, 'mean_word_length': 3.81408276714021, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3559660', 'n_tokens_mistral': 2484, 'n_tokens_neox': 2399, 'n_words': 759}