Giter VIP home page Giter VIP logo

chaos's Introduction

Chaos

A lightweight framework for writing REST services in Scala.

Chaos (Greek χάος, khaos) refers to the formless or void state preceding the creation of the universe or cosmos in the Greek creation myths. Chaos (the framework) precedes creation of a universe of services.

Why yet another framework?

At Mesosphere we're building REST services in Scala, and we wanted a solid foundation. We had experience with Dropwizard and Twitter Commons, which are both great Java frameworks, but are a bit hard to use from Scala. We also experimented with Play!, but it does many things besides REST, which adds unnecessary baggage.

Design Goals

We wanted a framework that

  • is easy to use
  • does one thing really well (REST)
  • feels good in Scala
  • is built on battle-tested and well-supported libraries
  • doesn't try to reinvent the wheel

Building Blocks

There are great JVM libraries for every part of a REST stack. Chaos just glues these together.

Getting Started

Requirements

  • JDK 1.8+
  • SBT 0.13.x+

Example App

There is an example app in [src/main/scala/mesosphere/chaos-examples/] (https://github.com/mesosphere/chaos/blob/master/chaos-examples/src/main/scala/mesosphere/chaos/examples/Main.scala). To run the example:

sbt run

Make requests to the example endpoints with HTTPie:

http localhost:8080/persons
http localhost:8080/persons name=Bunny age=42

Built in Endpoints

  • /ping - health check.
  • /metrics - metrics as JSON
  • /logging - configure log levels at runtime

Using Chaos in your Project

Chaos releases are available from Mesosphere's Maven repository.

Maven

To add Chaos to a Maven project, add this to your pom.xml:

<properties>
    <chaos.version>0.5.2</chaos.version>
</properties>

...

<repositories>
    <repository>
        <id>mesosphere-public-repo</id>
        <name>Mesosphere Public Repo</name>
        <url>http://downloads.mesosphere.io/maven</url>
    </repository>
</repositories>

...

<dependencies>
    <dependency>
        <groupId>mesosphere</groupId>
        <artifactId>chaos</artifactId>
        <version>${chaos.version}</version>
    </dependency>
</dependencies>

SBT

To add Chaos to an SBT project, add this to your build.sbt:

resolvers += "Mesosphere Public Repo" at "http://downloads.mesosphere.io/maven"

libraryDependencies ++= Seq(
  "mesosphere" % "chaos" % "0.5.2",
  "com.sun.jersey" % "jersey-bundle" % "1.17.1"
)

Getting Help

If you have questions, please post on the Chaos Users Group email list. The team at Mesosphere is also happy to answer any questions.

Authors

Current Users

  • Chronos, a fault tolerant job scheduler that handles dependencies and ISO8601 based schedules.

chaos's People

Contributors

aquamatthias avatar benmccann avatar billryan avatar connordoyle avatar drexin avatar florianleibert avatar gkleiman avatar guenter avatar johanatan avatar kadwanev avatar kensipe avatar levinotik avatar meichstedt avatar readmecritic avatar ssorallen avatar swartzrock avatar zunder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chaos's Issues

Get rid of Guice DI

In order to modularize components, get rid of Guice and replace it by the convenient way of Scala.

the REST api server doesn't response

we first met this issue in Chronos. Pasted here.

We encountered this issue twice in about 3 months, generally we have about 25K jobs per day and the api server may doesn't response sometime. when this issue happen, curl -X -L :/ping will hang up for ever.

see also mesos/chronos#285

Allow enforcing SSL connections

It's currently possible to pass a keystore to enable SSL, but once SSL is enabled it is still possible to access the same endpoints via HTTP. Chaos should allow enforcing SSL once it is enabled so HTTP connections are either redirected or refused to enforce encrypted connections.

Document release process

It would be nice if we could document which steps are necessary to publish a new release.

E.g.:

  • Bumping up versions in version.sbt
  • Creating tags
  • Testing certain essentials
  • Running a team city task

Whatever is necessary.

Allow logging to a file via a cli flag

The mesosphere marathon package for redhat logs via logger, which gets hoovered up into the systemd journal on RHEL/CentOS 7 or Fedora. It would be really nice to instead send this to a specific file in addition to the systemd journal.

Since marathon uses this library to do logging, the issue seems to be here and not in marathon directly. I've added this systemd service as a stopgap so we can use splunk to read marathon logs:

[Unit]
Description=Hack to log marathon logs to a file
After=network-online.target
Wants=network.target

[Service]
ExecStart=/bin/bash -c "/usr/bin/journalctl --quiet -lfu marathon >> /var/log/marathon/marathon.log"
Restart=always
RestartSec=1

[Install]
WantedBy=multi-user.target

And I've added Requires=marathon-logger.service to the marathon systemd unit to start marathon-logger on demand. Would it be possible to have chaos, and as a nice side effect, marathon support something like:

--log_level=info --log_file=/var/log/marathon/marathon.log

A simple logrotate config like this could be used so that chaos wouldn't natively need to rotate any logs:

/var/log/marathon/*.log {
    daily
    compress
    missingok
    rotate 30
    notifempty
    copytruncate
    delaycompress
}

Please upload to Maven Central

Hi,

I am trying to use Chronos, which depends on this particular project. Can you upload this artifact to Maven Central instead of using a proprietary Maven repo ?

Support credentialed CORS requests

A generic CORS header was added in commit d9c111b, but that does not fully fit the requirements of Agora.

As noted in MDN's requests with credentials, "when responding to a credentialed request, server must specify a domain, and cannot use wild carding." That means the /ping endpoint needs to return the requesting domain to allow the client to hit the credentialed end point.

  • Add Access-Control-Allow-Credentials: true header
  • Return requesting domain in Access-Control-Allow-Origin header

Provide jetty9 proxy artifact

All Marathon instances currently proxy to the current leader. Marathon uses its own proxy implementation with various issues.

Jetty 9 includes support for proxying. Thus it would probably make sense to upgrade to Jetty 9 to benefit from this functionality.

Since this is functionality which would be useful to frameworks other than Marathon, I would include the proxy artifact in Chaos, potentially even some utility support to provide proxying to another host dynamically.

Serve Gzipped assets if they exist

If a client requests an asset with Accept-Encoding: gzip, Chaos should serve a gzipped version of the asset if one exists. Right now Chaos ignores the heading and always serves the uncompressed version.

It appears that Jetty supports serving gzipped assets by calling ResourceHandler.setMinGzipLength with a value greater than 0. "1" seems like a reasonable value since every other value is equally arbitrary.

This is where the change looks like it should happen:

val handler = new ResourceHandler

Edit: The above example was to the wrong "ResourceHandler". Jetty handles Gzip compression with its Gzip Filter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.