<commit_before>


Gogeta
======

[![Build Status](https://travis-ci.org/arkenio/gogeta.png?branch=master)](https://travis-ci.org/arkenio/gogeta)

Gogeta is a dynamic reverse proxy which configuration is based on [etcd](https://github.com/coreos/etcd). It provides real time dynamic reconfiguration of routes without having to restart the process.

It is part of the nuxeo.io infrastructure.


How it works
------------

It is basically an HTTP cluster router that holds its configuration in etcd. Default behavior
is to use the IoEtcdResolver. For instance, when running gogeta like this :

        gogeta -etcdAddress="http://172.17.42.1:4001" \
               -domainDir="/domains" \
               -serviceDir="/services" \
               -templateDir="/usr/local/go/src/github.com/nuxeo/gogeta/templates"

Here is the workflow of the request
  * client asks for mycustomdomain.com
  * proxy looks at `/domains/mycustomdomain.com/[type,value]`
  * if `type` is `service` we look for `/services/{value}/1/location` which value is in the form

        {"host":"172.16.17.32","port":42567}

  * the request is proxied to `http://{host}:{port}/`

  * if `type` is uri
  * the request is proxied to the value of `/domains/mycustomdomain.com/value`


It is possible to have several instances of a service by differenciating them with the `serviceIndex`
key part :

    /services/myService/1/location
    /services/myService/2/location

Gogeta will loadbalance the requests on those two instances using a round robin implementation.



Sample configuration
--------------------

To summarize, here are the keys needed to proxy `customdomain.com` to `172.16.58.3:42654`


    /services/myService/1/location = {"host":"172.16.58.3", "port": 42654}
    /domains/mycustomdomain.com/type = service
    /domains/mycustomdomain.com/value = myService


Service Status
--------------

Optionnaly, services may have a status. This is a directory that is held at `/services/{serviceName}/{serviceIndex}/status`.
It holds three values:

 * `current`: The current status of the service in [stopped|starting|started|stopping|passivated]
 * `expected`: The expected status of the service [stopped|started|passivated]
 * `alive`: a heartbeat that the service must update.

Based on those values, Gogeta will serve wait pages with the according HTTP status code.

Configuration
-------------

Several parameters allow to configure the way the proxy behave :

 * `domainDir` allows to select the prefix of the key where it watches for domain
 * `serviceDir` allows to select the prefix of the key where it watches for environments
 * `etcdAddress` specify the address of the `etcd` server
 * `port` port to listen
 * `templateDir` a template directory for error status page
 * `resolverType`: choose the resolver to use
    * `Env`: EnvResolver
    * `Dummy`: DummyResolver
    * by default : IoEtcd

Debug
-----

You can log all goroutines callstack by sending a SIGUSR1 signal to the process.

    kill -SIGUSR1 `pidof gogeta`


Build and Test
--------------

Gogeta uses [GOM](https://github.com/mattn/gom) to build. Simply install GOM then :

    gom build
    gom install


To run the test :

    gom test

There are integration tests that may be run. To do so you need to start an `etcd`
server listening on port 4001. You may use the [Philip Southam](https://quay.io/repository/philipsoutham/etcd)
etcd server docker image that is very small for instance. After that run

    IT_Test=true gom test

If you want a more interactive test session, we use [GoConvey](https://github.com/smartystreets/goconvey)
that gives you a [web interface](http://localhost:8080) to show the tests execution. Each time a file is
saved, the tests are reevaluated. To run it :

    goconvey
    IT_Test=true goconvey


Run with Docker
---------------

You can run Gogeta thru Docker, since its image is build in the central Docker repository.

    /usr/bin/docker run --rm --name gogeta -p 7777:7777 arken/gogeta



Report & Contribute
-------------------

We are glad to welcome new developers on this initiative, and even simple usage feedback is great.
- Ask your questions on [Nuxeo Answers](http://answers.nuxeo.com)
- Report issues on this github repository (see [issues link](http://github.com/nuxeo/gogeta/issues) on the right)
- Contribute: Send pull requests!


About Nuxeo
-----------

Nuxeo provides a modular, extensible Java-based
[open source software platform for enterprise content management](http://www.nuxeo.com/en/products/ep),
and packaged applications for [document management](http://www.nuxeo.com/en/products/document-management),
[digital asset management](http://www.nuxeo.com/en/products/dam) and
[case management](http://www.nuxeo.com/en/products/case-management).

Designed by developers for developers, the Nuxeo platform offers a modern
architecture, a powerful plug-in model and extensive packaging
capabilities for building content applications.

More information on: <http://www.nuxeo.com/>
<commit_msg>Fix typo<commit_after>


Gogeta
======

[![Build Status](https://travis-ci.org/arkenio/gogeta.png?branch=master)](https://travis-ci.org/arkenio/gogeta)

Gogeta is a dynamic reverse proxy which configuration is based on [etcd](https://github.com/coreos/etcd). It provides real time dynamic reconfiguration of routes without having to restart the process.

It is part of the nuxeo.io infrastructure.


How it works
------------

It is basically an HTTP cluster router that holds its configuration in etcd. Default behavior
is to use the IoEtcdResolver. For instance, when running gogeta like this :

        gogeta -etcdAddress="http://172.17.42.1:4001" \
               -domainDir="/domains" \
               -serviceDir="/services" \
               -templateDir="/usr/local/go/src/github.com/nuxeo/gogeta/templates"

Here is the workflow of the request
  * client asks for mycustomdomain.com
  * proxy looks at `/domains/mycustomdomain.com/[type,value]`
  * if `type` is `service` we look for `/services/{value}/1/location` which value is in the form

        {"host":"172.16.17.32","port":42567}

  * the request is proxied to `http://{host}:{port}/`

  * if `type` is uri
  * the request is proxied to the value of `/domains/mycustomdomain.com/value`


It is possible to have several instances of a service by differenciating them with the `serviceIndex`
key part :

    /services/myService/1/location
    /services/myService/2/location

Gogeta will loadbalance the requests on those two instances using a round robin implementation.



Sample configuration
--------------------

To summarize, here are the keys needed to proxy `customdomain.com` to `172.16.58.3:42654`


    /services/myService/1/location = {"host":"172.16.58.3", "port": 42654}
    /domains/mycustomdomain.com/type = service
    /domains/mycustomdomain.com/value = myService


Service Status
--------------

Optionally, services may have a status. This is a directory that is held at `/services/{serviceName}/{serviceIndex}/status`.
It holds three values:

 * `current`: The current status of the service in [stopped|starting|started|stopping|passivated]
 * `expected`: The expected status of the service [stopped|started|passivated]
 * `alive`: a heartbeat that the service must update.

Based on those values, Gogeta will serve wait pages with the according HTTP status code.

Configuration
-------------

Several parameters allow to configure the way the proxy behave :

 * `domainDir` allows to select the prefix of the key where it watches for domain
 * `serviceDir` allows to select the prefix of the key where it watches for environments
 * `etcdAddress` specify the address of the `etcd` server
 * `port` port to listen
 * `templateDir` a template directory for error status page
 * `resolverType`: choose the resolver to use
    * `Env`: EnvResolver
    * `Dummy`: DummyResolver
    * by default : IoEtcd

Debug
-----

You can log all goroutines callstack by sending a SIGUSR1 signal to the process.

    kill -SIGUSR1 `pidof gogeta`


Build and Test
--------------

Gogeta uses [GOM](https://github.com/mattn/gom) to build. Simply install GOM then :

    gom build
    gom install


To run the test :

    gom test

There are integration tests that may be run. To do so you need to start an `etcd`
server listening on port 4001. You may use the [Philip Southam](https://quay.io/repository/philipsoutham/etcd)
etcd server docker image that is very small for instance. After that run

    IT_Test=true gom test

If you want a more interactive test session, we use [GoConvey](https://github.com/smartystreets/goconvey)
that gives you a [web interface](http://localhost:8080) to show the tests execution. Each time a file is
saved, the tests are reevaluated. To run it :

    goconvey
    IT_Test=true goconvey


Run with Docker
---------------

You can run Gogeta thru Docker, since its image is build in the central Docker repository.

    /usr/bin/docker run --rm --name gogeta -p 7777:7777 arken/gogeta



Report & Contribute
-------------------

We are glad to welcome new developers on this initiative, and even simple usage feedback is great.
- Ask your questions on [Nuxeo Answers](http://answers.nuxeo.com)
- Report issues on this github repository (see [issues link](http://github.com/nuxeo/gogeta/issues) on the right)
- Contribute: Send pull requests!


About Nuxeo
-----------

Nuxeo provides a modular, extensible Java-based
[open source software platform for enterprise content management](http://www.nuxeo.com/en/products/ep),
and packaged applications for [document management](http://www.nuxeo.com/en/products/document-management),
[digital asset management](http://www.nuxeo.com/en/products/dam) and
[case management](http://www.nuxeo.com/en/products/case-management).

Designed by developers for developers, the Nuxeo platform offers a modern
architecture, a powerful plug-in model and extensive packaging
capabilities for building content applications.

More information on: <http://www.nuxeo.com/>

{'fraction_non_alphanumeric': 0.11281128112811281, 'fraction_numerical': 0.014801480148014802, 'mean_word_length': 3.4603033006244424, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 12, 'lorem ipsum': 0, 'www.': 10, 'xml': 0}, 'pii_count': 8, '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': '6752790', 'n_tokens_mistral': 3074, 'n_tokens_neox': 2827, 'n_words': 1115}