microservices NAT Streaming Service __LEVEL

Get Started. It's Free
or sign up with your email address
microservices NAT Streaming Service __LEVEL by Mind Map: microservices NAT Streaming Service __LEVEL

1. Initialization [video]

1.1. npm init -y

1.2. npm i node-nats-streaming ts-node-dev typescript @types/node

1.3. configure typescript

1.3.1. npx tsc init

1.3.2. tsconfig.json

2. UDEMY CHAPTER VIDEO

2.1. docs.nats.io

2.2. Runs under docker

2.2.1. nats-streaming on docker/io

2.3. FEATURES [video]

2.3.1. works by subscriptions to channels

2.3.2. All events are stored in memory (flat files, or Database) array

2.3.2.1. Query all past events like ReplaySubject

2.3.2.2. if in database then it can recover from failure

2.4. ONLY STRINGS

2.4.1. Convert evrything to JSON

3. Deploying nats ss with skaffold

3.1. nats-depl.yaml

3.1.1. uses args to pass variables

3.1.1.1. -hbi

3.1.1.1.1. heartbit to check health

3.1.1.2. -hbt

3.1.1.2.1. how long the client has to responds

3.1.1.3. -hbf

3.1.1.3.1. how many attempts to discard the client

3.1.2. kubectl port-forward [pod-name] port:port

3.2. localhost:8222/streaming

3.2.1. http://localhost:8222/streaming/channelsz?subs=1

3.2.1.1. manually hardcode subs query variable

4. nat-test NAT Streaming Service Project

4.1. BOILER PLATES COMMON IMPLEMENTATIONS

4.1.1. COMMON vs PARTICULAR files organization

4.1.2. listener (base class)

4.1.2.1. listener.ts

4.1.2.1.1. import nats from 'node-nats-streammng'

4.1.2.1.2. connect

4.1.2.1.3. stan.on('connect;)

4.1.2.1.4. create subscription and subscribe with data

4.1.2.1.5. npm run listen

4.1.2.1.6. IMPORTANT FEATURES

4.1.2.2. An example of base CLASS

4.1.2.3. Instantiating the extended class

4.1.3. publisher (base class)

4.1.3.1. publsher.ts

4.1.3.1.1. import nats from 'node-nats-streammng'

4.1.3.1.2. initialize client / connect

4.1.3.1.3. on(connect)

4.1.3.1.4. npm run publish

4.1.3.2. Extneding CLASS

4.1.3.3. Instance File

4.2. STANDARIZING CHANNEL NAMES AND COSNTANTS

4.2.1. Define a subjects.ts ENUM types Typescript

4.2.1.1. Create an Event Type using the ENUM

4.2.1.1.1. modify the Event Class to set abstract property with Generics and ENUM

4.2.1.2. Modify baseClass to use Generics and the interface

4.2.1.2.1. <T extends interaface>

4.2.1.2.2. T['attribute']

4.2.2. create a SINGLETON NATS CLIENT Wrapper for listeners and publishers

4.2.2.1. INDEX (Express Initializer) SIngleton use 1

4.2.2.1.1. ROUTER Singleton Use 2

4.2.2.2. the graceful shutdown can't be in the singleton because it will shut down all processes

5. SOLVING CONCURRENCY ISSUES VIDEO

5.1. DESIGN DIAGRAM

5.1.1. The database allows the service to include the meaningful sequence number in the DESCRIPTION

5.1.1.1. in the service that receives the transaction we can have a sense of sequencing to solve any sync issues

5.1.2. IMPLEMENTED WITH MONGODB AND MONGOOSE