Giter Site home page Giter Site logo

iplocations's Introduction

Crezco Practical Task

Build a micro-service that would use any 3rd party location-from-IP address service.

  • External Provider - In my case I've opted to use FreeIP
  • Persistence - Uses MongoDb
    • Stores looked up values
    • Provides a fallback when the external provider lookup fails (If we've previously looked up that value successfully before)
  • Caching
    • Uses the built in InMemoryCache provided by AspNet.Core. An Improvement here would be to move to a distributed cache.
    • Expiration times are configurable in appsettings.
  • Testing - Using xUnit
    • Integration tests primarily used for overarching behaviours.
    • Unit tests mostly used to quickly test behaviours around isolated utilities. All done using xUnit.

Self-Review

  • Test coverage could be higher
    • Could have unit tests covering the FreeIpClient to ensure the test is being well formed.
    • Could use wiremock or a stub HttpMessageHandler in the integration tests instead of stubbing the IFreeApiClient.
    • Could have some unit tests around the DI setup to test different configurations. Though since there isn't much complex logic in the DI setup these tests aren't sorely missed.
  • Caching could do with some different configuration in cases where the external api fails and falls back to our persisted values. These values should be cached for less time (if at all).
    • Could also do with using a distributed cache to minimize duplicate calls from replicas needlessly increasing the external rate limit.

To Run

The simplest way to run is to execute the below:

docker-compose up -d ip-locations

Swagger UI will be available at http://localhost:5100/swagger/index.html

Tests

To run tests you must have a mongodb instance running. So you must run either the above snippet or:

docker-compose up -d mongodb

Then you can run dotnet test from the solution directory.

iplocations's People

Contributors

zjaime24601 avatar

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.