Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 23 20:45
    joroKr21 closed #1478
  • Sep 23 20:45

    joroKr21 on master

    Testing EndpointResults without… F.raiseError instead of throw Get rid of dispatcher in more p… and 5 more (compare)

  • Sep 23 20:45
    joroKr21 closed #1525
  • Sep 23 20:36
    joroKr21 edited #1525
  • Sep 23 20:35
    joroKr21 labeled #1525
  • Sep 23 20:35
    joroKr21 assigned #1525
  • Sep 23 20:35
    joroKr21 ready_for_review #1525
  • Sep 23 20:34
    joroKr21 edited #1525
  • Sep 23 20:34
    joroKr21 edited #1525
  • Sep 23 20:34
    joroKr21 edited #1525
  • Sep 23 20:32
    joroKr21 synchronize #1525
  • Sep 23 20:18
    joroKr21 synchronize #1525
  • Sep 23 19:40
    joroKr21 synchronize #1525
  • Sep 23 19:38
    joroKr21 synchronize #1525
  • Sep 23 19:22
    joroKr21 opened #1525
  • Sep 23 17:38

    joroKr21 on master

    Relax constraints from Async to… Merge pull request #1523 from j… (compare)

  • Sep 23 17:38
    joroKr21 closed #1523
  • Sep 23 17:37

    joroKr21 on master

    Fix doc links for Scala 2.12 - … Merge pull request #1524 from j… (compare)

  • Sep 23 17:37
    joroKr21 closed #1524
  • Sep 23 17:25
    joroKr21 labeled #1524
Alex Martins
@amartinsn
Ok @vkostyukov now you’ve got my attention :smile: Was finding writing those encoders/decoders boring and time consumming. Had already worked with jackson and scala module which also works smoothly with implicits. Will give it a go. Ta!
Vladimir Kostyukov
@vkostyukov
@amartinsn Great to hear that! I'm pretty sure @travisbrown will be excited to know that you're considering to use Circe in production.
Árni Hermann Reynisson
@arnihermann
@vkostyukov we're using circe in production at quizup
Vladimir Kostyukov
@vkostyukov
@arnihermann Cool! Are you using Finch by any chance? :)
Alex Martins
@amartinsn
All set with Circe gentlemen! @vkostyukov @travisbrown cleaner implementation ftw! Thanks
Travis Brown
@travisbrown
@amartinsn Great! That's really good to hear. There are still some corner cases where generic derivation doesn't work perfectly (mostly at this point I think due to scalac issues), so let us know if anything doesn't seem to be working correctly.
Alex Martins
@amartinsn
coolio @travisbrown !
Arnar Þór Sveinsson
@arnarthor
@vkostyukov Working on our first Finch services at QuizUp right now. Looks really good so far
Vladimir Kostyukov
@vkostyukov
@arnarthor Awesome news! Would love to see QuizUp in the adopters list once it's alive!
Alex Martins
@amartinsn
Can I add me company? It’s already live!
We are using Finch on video streaming platform
we implemented a service that returns live transmission details based on users location
Vladimir Kostyukov
@vkostyukov
@amartinsn Wow! It's awesome! I'd happy to accept a PR!
Alex Martins
@amartinsn
how does that work? A PR to add Globo.com to list of users?
Vladimir Kostyukov
@vkostyukov
Yep. Just fork a repo and make the changes in the README.
Alex Martins
@amartinsn
cool
Vladimir Kostyukov
@vkostyukov
Alex Martins
@amartinsn
will do it
Vladimir Kostyukov
@vkostyukov
@amartinsn Thanks! Really glad to hear that!
Alex Martins
@amartinsn
just did it @vkostyukov
Vladimir Kostyukov
@vkostyukov
@amartinsn Great! Thanks!
Travis Brown
@travisbrown
@amartinsn we'd also appreciate a PR here: https://github.com/twitter/finagle :smile:
Árni Hermann Reynisson
@arnihermann
cross post from finagle gitter: Is anyone interested in doing a hangout/skype session and talk a bit about finagle in person? A few of us at QuizUp are interested in learning about production setup and experiences with finagle.
@vkostyukov yeah what @arnarthor said -- we've been following finch since 0.6 and now we're finally writing a small service with it, so far it's looking great
Arnar Þór Sveinsson
@arnarthor
I am currently re-writing a NodeJS service in Finch and the code is so much cleaner and readable and about two thirds the amount of lines. Really love this
Alex Martins
@amartinsn
o/ for the Skype call
Arnar Þór Sveinsson
@arnarthor
Awesome! We would love to hear from you guys since we're just getting started with this
Vladimir Kostyukov
@vkostyukov
@arnarthor That's really sweet! Hope you don't mind if I tweet that :)
Arnar Þór Sveinsson
@arnarthor
Of course!
Árni Hermann Reynisson
@arnihermann
@vkostyukov is finch-test not a published module?
Travis Brown
@travisbrown
@arnihermann @vkostyukov The original purpose of finch-test was to abstract out shared code from the different JSON implementation projects' tests. ServiceSuite and ServiceIntegrationSuite are more generally useful, and should probably be published (possibly separately from the JSON stuff?).
Árni Hermann Reynisson
@arnihermann
yeah exactly
I've already copied them to my project
Travis Brown
@travisbrown
@arnihermann I added them during a pairing session with our Twitter OSS intern this summer, and tbh I then completely forgot that I wanted to figure out a place to publish them. I'm more than happy to +1 a PR or issue that does that.
Árni Hermann Reynisson
@arnihermann
ok I'll take a look tonight and create a PR
Travis Brown
@travisbrown
@arnihermann I think my vote would be to introduce a new json-test module with the JSON testing stuff so that finch-test won't need the Argonaut dependency, etc.
Árni Hermann Reynisson
@arnihermann
ok, cool, I'll do a PR with that, thanks
Alex Martins
@amartinsn

Hi guys, I need to implement a paged result for endpoints that returns a lot of data. I was thinking about implementing something using link rels, pointing to previous and next page, as well as informing the total number of pages the user has to navigate. The JSON response would look something like this:

{
  "users": [
    { "email": "john@example.com", "age": 17 },
    { "email": "ana@example.com", "age": 20 },
    { "email": "andrew@example.com", "age": 19 },
    { "email": "alex@example.com", "age": 34 },
    { "email": "riley@example.com", "age": 22 },
  ],
  "currentPage": 3,
  "totalPages": 6,
  "_links": {
    "previousPage": "/users?page=2",
    "nextPage": "/users?page=4"
  }
}

To do that, one idea would be to create a PagedResult class

case class PagedResult[A](
  currentPage: Int, 
  totalPages: Int, 
  entries: List[A]) {

  def nextPage: String =
    "...."

  def previousPage: String =
    "..."
}

... and then initialize it with the results fetched from database queries.

val list: Endpoint[PagedResult[User]] =
  get("users" ? pagination) { pageInfo: Pagination =>
    val result = for {
      (totalPages, entries) <- users.list(pageInfo)
    } yield PagedResult(pageInfo.page, totalPages, entries)

    Ok(result)
  }

But I'm struggling to find out how to come up with the values for previousPage and nextPage on PagedResult as I don't have any reference to the Request object which contains the requested URI. Any help with that, please? And also I would like to hear your thoughts on that, maybe creating a Finch extension for creating Hypermedia APIs.

Vladimir Kostyukov
@vkostyukov

@amartinsn I'd vote for defining a new property on PagedResult(resource: String, ...) and then in the list endpoint:

... yield PagedResult("users", pageInfo.page, totalPages, entries)

Does it make any sense?

Alex Martins
@amartinsn
yeah it makes a lot of sense @vkostyukov !
thanks
Alex Martins
@amartinsn
The tricky part that I’m currently stuck is to get the URI info out of the request instance to generate next and previous URIs
Arnar Þór Sveinsson
@arnarthor
This message was deleted

@amartinsn shouldn't you be able to do something like

post("foo" ? param("next")) { (next: Int) => ???

Or am I not understanding your requirement?

From there you could use the next param as your prev, and then generate a new next when you have the data and know what your cursor should point at?
Alex Martins
@amartinsn
The problem is not with the next or previous page number, but to find out what’s the URI to create those ‘nextPage' and ‘previousPage’ urls @arnarthor.
Vladimir Kostyukov
@vkostyukov
@amartinsn Isn't it a known information from the Endpoint itself? I mean post("users" ? param("page")) { .. } matches /users?page=X.
Arnar Þór Sveinsson
@arnarthor
I see, don't you have that in your endpoint then? You know it's the "users" endpoint
Alex Martins
@amartinsn
This is what are you talking about?
val list: Endpoint[PagedResult[User]] =
    get("users" ? pagination) { pageInfo: Pagination =>
      val result = for {
        (totalPages, entries) <- users.list(pageInfo)
      } yield PagedResult(
          currentPage = pageInfo.page,
          totalPages = totalPages, 
          entries = entries,
          uri = "/users"
        )

      Ok(result)
    }
Vladimir Kostyukov
@vkostyukov
@amartinsn Yep. Looks pretty close to what I had in mind.