Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/titanlien/asynchronous-events

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/titanlien/asynchronous-events

  • v0.0.0-20210726140608-f17d5d5facdc
  • Source
  • Go
  • Socket score

Version published
Created
Source

Overview of Milestone 4 Implementation

What Was Created?

In this milestone:

  1. a Go Kafka consumer was created called Warehouse
  2. a Go Kafka consumer was created called Notification
  3. a Go Kafka consumer was created called Shipper

How to Test?

I was able to test all of the code created in this milestone on my local machine. The instructions below assume you are running on your local machine. I implemented this on a Mac, so references to the command-line will show as a UNIX shell.

  1. Kafka and Zookeeper need to be running
    1. The OrderReceived topic should be created
    2. The OrderPickedAndPacked topic should be created
    3. The Notification topic should be created
    4. The DeadLetterQueue topic should be created
  2. The Postgress database needs to be running
    1. The right database, schema and table need to be created: click here for more information
  3. The Order service needs to be running (assumes you are in the milestone5/code folder)
    1. If this is the first time you are running this code, you will need to setup Go modules
      1. In your ~/.bash_profile, make sure you have the following ENV var set: export GO111MODULE=on and make sure the file is sourced.
      2. Initialize Go modules
        $ go mod init
        
        $ go mod tidy
        
    2. Run the Order service
      $ go run order/main.go
      
  4. The Inventory consumer needs to be running (assumes you are in the milestone5/code folder)
    1. If this is the first time you are running this code, you will need to setup Go modules
      1. In your ~/.bash_profile, make sure you have the following ENV var set: export GO111MODULE=on and make sure the file is sourced.
      2. Initialize Go modules
        $ go mod init
        
        $ go mod tidy
        
    2. Run the Inventory consumer service
      $ go run inventory/main.go
      
  5. The Warehouse consumer needs to be running (assumes you are in the milestone5/code folder)
    1. If this is the first time you are running this code, you will need to setup Go modules
      1. In your ~/.bash_profile, make sure you have the following ENV var set: export GO111MODULE=on and make sure the file is sourced.
      2. Initialize Go modules
        $ go mod init
        
        $ go mod tidy
        
    2. Run the Warehouse consumer service
      $ go run warehouse/main.go
      
  6. The Notification consumer needs to be running (assumes you are in the milestone5/code folder)
    1. If this is the first time you are running this code, you will need to setup Go modules
      1. In your ~/.bash_profile, make sure you have the following ENV var set: export GO111MODULE=on and make sure the file is sourced.
      2. Initialize Go modules
        $ go mod init
        
        $ go mod tidy
        
    2. Run the Notification consumer service
      $ go run notification/main.go
      
  7. The Shipper consumer needs to be running (assumes you are in the milestone5/code folder)
    1. If this is the first time you are running this code, you will need to setup Go modules
      1. In your ~/.bash_profile, make sure you have the following ENV var set: export GO111MODULE=on and make sure the file is sourced.
      2. Initialize Go modules
        $ go mod init
        
        $ go mod tidy
        
    2. Run the Shipper consumer service
      $ go run shipper/main.go
      
  8. Send a HTTP request to the order service:
    $ curl -v -H "Content-Type: application/json" -d '{"id":"6e042f29-350b-4d51-8849-5e36456dfa48","products":[{"productCode":"12345","quantity":2}],"customer":{"firstName":"Tom","lastName":"Hardy","emailAddress":"tom.hardy@email.com","shippingAddress":{"line1":"123 Anywhere St","city":"Anytown","state":"AL","postalCode":"12345"}}}' http://localhost:8080/orders
    
  9. You should see output in the console of the order service, and no errors. You can also check the contents of the OrderReceived topic in Kafka.
    $ $KAFKA_HOME/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic OrderReceived --from-beginning
    
  10. You can also check the contents of the Notification topic in Kafka.
    $ $KAFKA_HOME/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic Notification --from-beginning
    
  11. You should see output in the console of the inventory consumer, and no errors.
  12. You should see output in the console of the warehouse consumer, and no errors.
  13. You should see output in the console of the notification consumer, and no errors.
  14. To check the the shipping consumer, you will need to manually publish a message to the OrderPickedAndPacked topic in Kafka.
    $ $KAFKA_HOMEbin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic OrderPickedAndPacked
    
    Then you can past a payload like this
    {"EventBase":{"EventID":"4a651ef8-a851-4d77-a58b-3d8af748a570","EventTimestamp":"2020-08-16T16:03:05.258542-04:00"},"EventBody":{"id":"c6b37316-b4da-4b25-94c8-14c08bad95e6","products":[{"productCode":"12345","quantity":2}],"customer":{"firstName":"Tom","lastName":"Hardy","emailAddress":"tom.hardy@email.com","shippingAddress":{"line1":"123 Anywhere St","city":"Anytown","state":"AL","postalCode":"12345"}}}}
    
  15. You should see output in the console of the shipper consumer, and no errors.

FAQs

Package last updated on 26 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc