Giter Site home page Giter Site logo

theiterators / akka-http-microservice Goto Github PK

View Code? Open in Web Editor NEW
752.0 752.0 232.0 232 KB

Example of http (micro)service in Scala & akka-http

License: MIT License

Scala 99.33% Procfile 0.67%
akka akka-http boilerplate microservice scala skeleton starter-kit template

akka-http-microservice's People

Contributors

frankbe avatar gitter-badger avatar jaceklaskowski avatar jeroenr avatar jglodek avatar jkutner avatar karthikkolli avatar kirankgollakota avatar ktoso avatar luksow avatar marcin-rzeznicki avatar muuki88 avatar pk044 avatar rpiotrow avatar scala-steward avatar vikraman 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

akka-http-microservice's Issues

Update to Akka Streams 1.0

Please update to Akka Streams 1.0.
This template is rather high up in google search results, it would be awesome if it would be up to date. πŸ˜„

Thanks!

No more free public api from telize.com

From http://www.telize.com:

The public API will permanently shut down on November 15th, 2015. More information can be found here [http://www.cambus.net/adventures-in-running-a-free-public-api/].
To continue using Telize after this date, please spin up your own instance or subscribe to a paid plan.

unable to start the project after getting it with activator ui

HI there,

as soon as I try to build the project I'm getting this:

stondo@H97-D3H:~/dev/scala/akka-http-microservice-quickstart$ sbt
[info] Loading project definition from /home/stondo/dev/scala/akka-http-microservice-quickstart/project
[error] [/home/stondo/dev/scala/akka-http-microservice-quickstart/build.sbt]:64: ';' expected but 'true' found.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?

Anyone know what might be wrong? Installed Scala 2.11.7 with sdkman.io and using Ubuntun 14.04. Sbt version is 0.13.9
Thanks in advance for your help

JVM Heap Memory Leak Issue

I have used this template to create a search rest API for my project. I have deployed my micro service in AWS EBS with Docker setup. I have allocate 512 MB Memory for docker. When I request my rest API from some tool(post man/j meter) the heap memory and CPU utilization was increased, after the stop the request CPU utilization decreased but heap memory not decreased instead when the next set ot request comes heap memory increased again.
There is any was to fix this issue by clearing the unused objects from the Scala code. I need to close(shutdown) the actor object manually or it will be deleted by the JVM's GC.

ERROR running akka-http-microservice Activator template

Error running akka-http-microservice Activator template
Unable to run example template: akka-http-microservice from the Activator

Project builds, but on running, unable to access URL, http://localhost:9000/ip/8.8.8.8 getting 'Internal Server Error'

Error on running service: [ERROR] [04/21/2016 12:06:35.506] [default-akka.actor.default-dispatcher-10] [akka://default/user/StreamSupervisor-0/flow-2-0-unknown-operation] Error in stage [One2OneBidi]: Inner stream finished before inputs completed. Outputs might have been truncated. (akka.http.impl.util.One2OneBidiFlow$OutputTruncationException$)

This is just with code taken directly from downloaded template *.zip file.

Running on Mac OSx, El Capitan. Running Scala v2.10.3. Activator v1.3.9

Errors should be JSONified (and not assume Accept: text/plain header)

Errors should really be JSON responses with appropriate Content-Types headers.

The following sends a JSON request using Accept and Content-Types set to application/json:

➜  ~  http -j http://localhost:9000/ip/8.8
HTTP/1.1 406 Not Acceptable
Content-Length: 78
Content-Type: text/plain; charset=UTF-8
Date: Sun, 01 Feb 2015 10:43:21 GMT
Server: akka-http/2.3.9

Resource representation is only available with these Content-Types:
text/plain

When I explicitly say I'm accepting test/plain it's fine:

➜  ~  http -j http://localhost:9000/ip/8.8 Accept:text/plain,application/json
HTTP/1.1 400 Bad Request
Content-Length: 24
Content-Type: text/plain; charset=UTF-8
Date: Sun, 01 Feb 2015 10:44:13 GMT
Server: akka-http/2.3.9

8.8: incorrect IP format

The same happens with the following when it's implicitly assumed POST in JSON Accept and Content-Types headers:

➜  ~  http http://localhost:9000/ip/8.8.8.8 ip1=8.8.8.8 ip2=8.8
HTTP/1.1 406 Not Acceptable
Content-Length: 78
Content-Type: text/plain; charset=UTF-8
Date: Sun, 01 Feb 2015 10:46:06 GMT
Server: akka-http/2.3.9

Resource representation is only available with these Content-Types:
text/plain

With explicitly accepting non-JSON responses using Accept:text/plain it works:

➜  ~  http http://localhost:9000/ip/8.8.8.8 Accept:text/plain,application/json ip1=8.8.8.8 ip2=8.8
HTTP/1.1 400 Bad Request
Content-Length: 24
Content-Type: text/plain; charset=UTF-8
Date: Sun, 01 Feb 2015 10:45:07 GMT
Server: akka-http/2.3.9

8.8: incorrect IP format

hrefs in tutorial reference non-existent ids/names

As an example:

<li>learn <a href="#tutorial/1" class="shortcut">what a microservice is</a>,</li>

but there's no anchor defined

<div> <h2>What is a microservice?</h2> <p>

An id attribute or an <a name>...</a> element needs to be defined for these to work.

Any service management solution?

Hi, how to manage a akka-http-microservice?

For example, configuration, service registry & discovery, log, metrics, tracing, load balancing, rate limit...

Test for rejction

I have added validation to the case class and changed the tests to use Route.seal or inside(rejection). But the test fails with error

  • should respond with bad request on incorrect IP format *** FAILED ***
    [info] java.lang.IllegalArgumentException: requirement failed: wrong IP address

It's similar to this question but I Post doesn't accept JsObject

case class IpPairSummaryRequest(ip1: String, ip2: String) { require(ip2.split('.').map(oktet => Try(oktet.toInt)).map(x => x.getOrElse(-1)).map({s => s >= 0 && s <= 255}).forall(x => x), "wrong IP address") }

tests

it should "respond with bad request on incorrect IP format" in {

  Post(s"/ip", IpPairSummaryRequest(ip1Info.query, "asdfg")) ~> Route.seal(routes) ~> check {
    status shouldBe BadRequest
    responseAs[String].length should be > 0
  }

  Post(s"/ip", IpPairSummaryRequest(ip1Info.query, "asdfg")) ~> routes ~> check {
    inside(rejection) {
      case ValidationRejection("requirement failed: wrong IP address", _) =>
    }
  }
}

Consider host-level api for sending requests

Please note there's a couple great discussions discouraging the use of Source.single when sending a request list is done in the AkkaHttpMicroservice:

https://doc.akka.io/docs/akka-http/current/client-side/host-level.html?language=scala#examples

https://stackoverflow.com/questions/44241920/akka-http-host-level-client-side-api-source-queue-pattern

At this place we previously showed an example that used the Source.single(request).via(pool).runWith(Sink.head). In fact, this is an anti-pattern that doesn’t perform well. Please either supply requests using a queue or in a streamed fashion as shown below.

You might want to consider just adding a comment in your code referencing this so as to not advertise this anti-pattern as the Akka docs describe it (if not refactor the code a bit to make use of host-level api)

Marshalling object

Can I do this for a case object?

trait Protocols extends DefaultJsonProtocol {
Β  implicit val ipInfoFormat = jsonFormat5(IpInfo.apply)
Β  implicit val ipPairSummaryRequestFormat = jsonFormat2(IpPairSummaryRequest.apply)
Β  implicit val ipPairSummaryFormat = jsonFormat3(IpPairSummary.apply)
}

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.