Giter Site home page Giter Site logo

hungngomobile / broker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ibmstocktrader/broker

0.0 1.0 0.0 52.27 MB

Controller microservice coordinating downstream microservices

License: Apache License 2.0

Java 63.19% HTML 34.56% Dockerfile 2.25%

broker's Introduction

This microservice is the controller for the IBM Stock Trader application. The various clients talk solely to this microservice, which then takes care of coordinating calls to the downstream microservices and merging the results. The following operations are available:

GET / - gets summary data for all brokers.

POST /{owner} - creates a new broker for the specified owner.

GET /{owner} - gets details for the specified broker.

PUT /{owner} - updates the broker for the specified owner (by adding a stock).

DELETE /{owner} - removes the broker for the specified owner.

GET /{owner}/returns - gets the return on investment for this broker.

POST /{owner}/feedback - submits feedback (to the Watson Tone Analyzer)

All operations return JSON. A broker object contains fields named owner, total, loyalty, balance, commissions, free, sentiment, and nextCommission, plus an array of stocks. A stock object contains fields named symbol, shares, commission, price, total, and date. The only operation that takes any query params is the PUT operation, which expects params named symbol and shares. Also, the feedback operation takes a JSON object in the http body, with a single field named text.

For example, doing a PUT http://localhost:9080/broker/John?symbol=IBM&shares=123 (against a freshly created broker for John) would return JSON like {"owner": "John", "total": 19120.35, "loyalty": "Bronze", "balance": 40.01, "commissions": 9.99, "free": 0, "sentiment": "Unknown", "nextCommission": 8.99, "stocks": [{"symbol": "IBM", "shares": 123, "commission": 9.99, "price": 155.45, "total": 19120.35, "date": "2017-06-26"}]}.

The above REST call would call the Portfolio microservice to buy the shares of stock. If configured (via the USE_ACCOUNT environment variable), it would also call the Account microservice to determine the new loyalty level, the account balance, and other such optional fields. If not configured to use the Account microservice, it will return -1 for each optional number and "Unknown" for each optional string.

Prerequisites for Kubernetes Deployment

This project requires one secret called jwt.

kubectl create secret generic jwt -n stock-trader --from-literal=audience=stock-trader --from-literal=issuer=http://stock-trader.ibm.com

Build and Deploy to Kubernetes

To build broker clone this repo and run:

mvn package
docker build -t broker:latest -t <REPO>/stock-trader/broker:latest .
docker tag broker:latest <REPO>/stock-trader/broker:latest
docker push <REPO>/stock-trader/broker:latest

Use the WebSphere Liberty helm chart to deploy the Broker microservice:

helm repo add ibm-charts https://raw.githubusercontent.com/IBM/charts/master/repo/stable/
helm install ibm-charts/ibm-websphere-liberty -f <VALUES_YAML> -n <RELEASE_NAME> --tls

broker's People

Contributors

ana-bezerra avatar andrewdes avatar brutif avatar cvignola avatar dependabot[bot] avatar greghint avatar jwalcorn avatar karricar avatar kittysmithita avatar leochr avatar maxveit avatar raunak-s avatar rtclauss 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.