This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get dependencies | |
const express = require('express'); | |
const path = require('path'); | |
const http = require('http'); | |
const bodyParser = require('body-parser'); | |
// Get our API routes | |
const api = require('./server/routes/api'); | |
const app = express(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from "@angular/core"; | |
import { Observable } from "rxjs"; | |
import * as io from "socket.io-client"; | |
import { IMessage, ISocketItem } from "../../models"; | |
@Injectable() | |
export class SocketService { | |
private name: string; | |
private host: string = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { TestService } from './../services/test.service'; | |
import { Component, OnInit } from '@angular/core'; | |
@Component({ | |
selector: 'app-comp1', | |
templateUrl: './comp1.component.html', | |
styleUrls: ['./comp1.component.css'] | |
}) | |
export class Comp1Component implements OnInit { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
# Serve feature from new service for internal network | |
RewriteCond expr "%{HTTP:X-FORWARDED-FOR} -ipmatch '171.78.205.170/24'" | |
RewriteRule ^/feature/(.*)$ ${NEW_SERVICE_URL}/$1 [P,L] | |
# Proxy everything else to legacy application | |
RewriteRule ^/(.*) ${LEGACY_URL}/$1 [P] | |
ProxyPassReverse / ${LEGACY_URL}/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Sample Implementation of Circuit Breaker using hystrixjs in NodeJS | |
It uses reactive principles | |
Link : https://www.npmjs.com/package/hystrixjs | |
*/ | |
var CommandsFactory = require('hystrixjs').commandFactory; | |
var serviceCommand = CommandsFactory.getOrCreate("Service on port :" + service.port + ":" + port) | |
.circuitBreakerErrorThresholdPercentage(service.errorThreshold) | |
.timeout(service.timeout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: shopping-management | |
spec: | |
containers: | |
- name: shopping-management | |
image: shopping-service | |
resources: | |
requests: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var q = 'tasks'; | |
var open = require('amqplib').connect('amqp://localhost'); | |
// Publisher | |
open.then(function(conn) { | |
return conn.createChannel(); | |
}).then(function(ch) { | |
return ch.assertQueue(q).then(function(ok) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Parses the request and dispatches multiple concurrent requests to each | |
* internal endpoint. Results are aggregated and returned. | |
*/ | |
function serviceDispatch(req, res) { | |
var parsedUrl = url.parse(req.url); | |
/*Service is where we maintain the requests which we want to aggregate/ | |
Service.findOne({ url: parsedUrl.pathname }, function(err, service) { |