Git Product home page Git Product logo

ex_roads's Introduction

Hi/Olá!

  • 🔭 Digging Software Development Metrics at SourceLevel.io
  • 🌱 I’m currently learning Elixir
  • 💬 Ask me about Ruby
  • ⚡ Fun fact: I enjoy playing jRPG games 🎮 and to cycle 🚴

Stats

Technologies & Tools

Ruby Elixir Swift Tmux Vim

ex_roads's People

Contributors

robospecta avatar wevtimoteo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

garaujodev

ex_roads's Issues

Async requests cause FunctionClauseError

Clone of kmonline#1 (comment)

Description

The documentation says that:

The options keyword can also take special entry for headers and options, which are passed to the underlying Request. See the documentation of HTTPoison for details.

This is misleading because it does not appear to support all available HTTPoison options. Specifically, when trying to conduct a GoogleRoads.snap_to_roads\3 request asynchronously using the stream_to option provided by HTTPoison, an exception occurs.

Steps To Reproduce

  1. Run the following command from the iex console.
    GoogleRoads.snap_to_roads("-37.78926|145.29083,-37.78939|145.29189,-37.78914|145.29193,-37.78865|145.29203,-37.78786|145.29219,-37.78787|145.29246,-37.78784|145.2927", true, options: [stream_to: self()])

Expected Outcome

It returns a map containing the reference to the process id where the async response of the request will be streamed.

Actual Outcome

It returns a FunctionClauseError
Capture

Reason

This occurs because the underlying HTTPoison response returned when the stream_to option is passed is not a normal %HTTPoison.Response{} but a %HTTPoison.AsyncResponse{}. In the GoogleRoads wrapper this kind of response hasn't been pattern matched, leading to an exception where none of the available clauses match. More specifically, the async response does not contain a body field like the one found in a normal response, but instead contains an id field referencing the process id it is streaming to.

Recommendations

This type of response should be pattern matched providing the ability to return a response containing the process id rather than a body. I am happy to write this and submit a pull request for this.

I envisage the code to be as simple as def wrap({:ok, %{id: id}}), do: {:ok, %{id: id}} plus associated unit tests if there is any. I have tested this change locally and it appears to behave correctly.

Thanks,
Robospecta

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.