Coder Social home page Coder Social logo

fortuneteller's Introduction

Fortune Teller

This is a demo for Steeltoe OSS. If you are looking for slides that came along with a presentation of this demo, please look here.

This variant of the fortune teller application includes two .NET applications that can communicate with each other over HTTP and RabbitMQ. FortuneTellerService is a WebAPI project that stores fortunes in a PostgreSQL database. When fortunes are requested, sometimes they are accompanied by messages from the great beyond. When those messages are encountered, the service will send them to a queue in RabbitMQ. The FortuneTellerUI is a Razor Pages project that is used to request fortunes over HTTP from the fortune service (using Eureka or Spring Cloud Registry to locate the service) and read messages from the queue. Both applications get configuration data from a Spring Cloud Config Server.

Notable Features

Externalizing and reloading configuration

Both applications are configured to read from a Spring Cloud Config Server. The UI application is configured to bind config data to FortuneServiceOptions.cs using IOptions. As such, the values will be updated whenever the underlying values in one of the included ConfigurationProviders change. Using this pattern in combination with the polling feature in Steeltoe's ConfigServer configuration provider and/or the /refresh actuator will allow you to update an application's configuration values without having to restart your application.

Working with service bindings

The connections to RabbitMQ, PostgreSQL and Eureka (Spring Cloud Service Registry) are all managed by Steeltoe Connectors. The connection parameters (default values and those configured in these examples) will be automatically updated/overridden when the application is bound to service instances in TAS/Cloud Foundry

Actuators

Steeltoe Actuators are included in both projects and will automatically work with Apps Manager when deployed on TAS.

Client-side load balancing and service discovery

FortuneTellerService is configured to register with Eureka. FortuneTellerUI is configured to read Eureka's service registry and through the integration with HttpClientFactory, automatically updates the URI on each request to the fortune service with the address of running service instance using a round robin algorithm to evenly distribute traffic to registered service instances.

Running Backing Services Locally

The fortune teller requires a config server, registry server, database server and queue server. The easiest way to get these locally is using docker, as demonstrated below.

Spring Cloud Config Server

Run or use the contents of ./config-repo/start-config-server.ps1

Eureka Server

docker run --rm -ti -p 8761:8761 --name steeltoe-eureka steeltoeoss/eureka-server

PostgreSQL

docker run --rm -ti -p 5432:5432 --name steeltoe-postgres -e POSTGRES_DB=steeltoe -e POSTGRES_USER=steeltoe -e POSTGRES_PASSWORD=steeltoe postgres:alpine

RabbitMQ

docker run --rm -ti -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:3-management

fortuneteller's People

Contributors

timhess avatar

Watchers

 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.