Giter Club home page Giter Club logo

go-nats-keyvalue-storage's Introduction

Basic NATS Key-Value Store Implementation in Golang

This project implements a basic key-value store using the NATS messaging system in Golang. The key-value store is designed to be a service discovery mechanism for microservices, allowing them to register and discover each other's endpoints.

The key-value store consists of two main components:

  1. KV: The KV component handles incoming requests to put and delete key-value pairs. It publishes these updates to a NATS stream, which is consumed by the Watcher component.
  2. Watcher: The Watcher component subscribes to the NATS stream and processes updates to the key-value store. It prints the updated key-value pairs to the console.

Run Instructions,

  1. Start the Watcher component by running the watcher/main.
  2. Start the KV component by running the kv/main.go in a separate terminal window.
  • Command: #1,
  go run watcher/main.go
  • Response: #1,
services.orders @ 1 -> "https://localhost:8080/orders" (op: KeyValuePutOp)
services.orders @ 2 -> "https://localhost:8080/v1/orders" (op: KeyValuePutOp)
services.consumers @ 3 -> "http://localhost:8080/v2/consumers" (op: KeyValuePutOp)
services.consumers @ 4 -> "" (op: KeyValueDeleteOp)
  • Command: #2,
  go run kv/main.go
  • Response: #2,
services.orders @ 1 -> "https://localhost:8080/orders"
services.orders @ 2 -> "https://localhost:8080/v1/orders"
services.orders @ 2 -> "https://localhost:8080/v1/orders"
KV stream name: KV_discovery
services.consumers @ 3 -> "http://localhost:8080/v2/consumers"

go-nats-keyvalue-storage's People

Contributors

rohanyh101 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.