Skip to content

Commit

Permalink
add script for manual install, refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tysonrm committed Jan 3, 2023
1 parent e832e21 commit 335e9f2
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 73 deletions.
16 changes: 8 additions & 8 deletions dist/867.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/867.js.map

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4337,7 +4337,7 @@ function pickOrder(service) {
eventTime: new Date().toISOString(),
eventSource: 'orderService',
eventData: {
replyChannel: 'orderChannel',
respChannel: 'orderChannel',
commandName: 'pickOrder',
commandArgs: {
lineItems: order.orderItems,
Expand Down Expand Up @@ -5619,23 +5619,23 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar

function wasmGetPublicIpAddress() {
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
var bytes;
var chunks;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
bytes = [];
chunks = [];
return _context.abrupt("return", new Promise(function (resolve) {
http__WEBPACK_IMPORTED_MODULE_0___default().get({
hostname: 'checkip.amazonaws.com',
method: 'get'
}, function (response) {
response.on('data', function (chunk) {
return bytes.push(chunk);
}, function (res) {
res.on('data', function (chunk) {
return chunks.push(chunk);
});
response.on('end', function () {
res.on('end', function () {
resolve({
address: bytes.join('').trim()
address: chunks.join('').trim()
});
});
});
Expand Down Expand Up @@ -10833,7 +10833,7 @@ var Registry = {
var eventName = /*'outOfStock';*/'orderPicked';
this.sendEvent({
emitEvent: emitEvent,
topic: event.eventData.replyChannel,
topic: event.eventData.respChannel,
eventName: eventName,
eventData: {
warehouse_addr: warehouseAddress,
Expand Down
2 changes: 1 addition & 1 deletion dist/main.js.map

Large diffs are not rendered by default.

Binary file removed forkrun
Binary file not shown.
25 changes: 25 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export PORT=8080
cd ..
# git clone https://github.com/module-federation/aegis
# git clone https://github.com/module-federation/aegis-host
cd aegis
yarn
yarn build
cd ../aegis-app
yarn
yarn build
cd ../aegis-host
yarn
cd ../aegis-app
nohup node repo.js 8000 dist &
nohup node repo.js 8001 cache &
cd ../aegis
yarn link
cd ../aegis-host
yarn link @module-federation/aegis
yarn build
cd ../aegis
nohup node watch.mjs &
cd ../aegis-host
nohup node watch.mjs &
node --title aegis src/bootstrap.js | tee public/aegis.log
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"url": "https://github.com/module-federation/aegis-app"
},
"scripts": {
"install": "./install.sh",
"build": "yarn build-local",
"start": "./start.sh",
"watch": "node watch.mjs",
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/inventory-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function pickOrder (service) {
eventTime: new Date().toISOString(),
eventSource: 'orderService',
eventData: {
replyChannel: 'orderChannel',
respChannel: 'orderChannel',
commandName: 'pickOrder',
commandArgs: {
lineItems: order.orderItems,
Expand Down
10 changes: 5 additions & 5 deletions src/adapters/wasm-public-ipaddr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import http from 'http'

export function wasmGetPublicIpAddress () {
return async function () {
const bytes = []
const chunks = []
return new Promise(resolve => {
http.get(
{
hostname: 'checkip.amazonaws.com',
method: 'get'
},
response => {
response.on('data', chunk => bytes.push(chunk))
response.on('end', function () {
resolve({ address: bytes.join('').trim() })
res => {
res.on('data', chunk => chunks.push(chunk))
res.on('end', function () {
resolve({ address: chunks.join('').trim() })
})
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/service-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const Registry = {
const eventName = /*'outOfStock';*/ 'orderPicked'
this.sendEvent({
emitEvent,
topic: event.eventData.replyChannel,
topic: event.eventData.respChannel,
eventName,
eventData: { warehouse_addr: warehouseAddress, externalId },
eventSource: 'inventoryService'
Expand Down
2 changes: 1 addition & 1 deletion src/wasm/asconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"options": {
"bindings": "esm"
}
}
}
76 changes: 30 additions & 46 deletions src/wasm/assembly/index.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
// The entry file of your WebAssembly modul

@external('env', 'console.log')
declare function consoleLog (s: string): void
@external('aegis', 'callJsFunction')
declare function callJsFunction (kv: string[][]): string[][]
declare function consoleLog(s: string): void

export function getModelName (): string {
return 'wasm'
export function getModelName(): string {
return 'wasmtwo'
}

export function getEndpoint (): string {
return 'wasm'
export function getEndpoint(): string {
return 'wasmtwo'
}

export function getDomain (): string {
return 'wasm'
export function getDomain(): string {
return 'wasmtwo'
}

export function update (changes: string[][]): void {
export function update(changes: string[][]): void {
const runValidation: boolean = true
}

export const ArrayOfStrings_ID = idof<string[]>()
const KEY: i32 = 0
const VAL: i32 = 1

function findVal (key: string, kv: string[][]): string {
function findVal(key: string, kv: string[][]): string {
for (let i = 0; i < kv.length; i++) {
if (key === kv[i][0]) {
return kv[i][1].toString()
if (key === kv[i][KEY]) {
return kv[i][VAL].toString()
}
}
return ''
}

export function modelFactory (kv: string[][]): string[][] {
export function modelFactory(kv: string[][]): string[][] {
const arr = new Array<string[]>(4)
arr[0] = ['wasm', 'AssemblyScript']
arr[1] = ['fibonacci', findVal('fibonacci', kv) || '20']
Expand All @@ -41,50 +40,35 @@ export function modelFactory (kv: string[][]): string[][] {
return arr
}

export function getPorts (): string[][] {
let ports = new Array<string[]>(3)
export function getPorts(): string[][] {
const ports = new Array<string[]>(2)
//port,service,type,consumesEvent,producesEvent,callback,undo
ports = [
[
'runFibonacci',
'fibonacciService,inbound,fibonacciBegin,fibonacciEnd,runFibonacci,'
],
['mlOpsLoad', 'mlOps,inbound,mlOpsLoad,mlOpsTrain,mlOpsLoad'],
['mlOpsTrain', 'mlOps,inbound,mlOpsTrain,mlOpsRun,mlOpsTrain'],
[
'wasmGetPublicIpAddress',
'wasm,outbound,mlOpsTrain,wasmGotIp,wasmGetPublicIpAddress'
]
ports[0] = [
'runFibonacci',
'fibonacciService,inbound,fibonacciBegin,fibonacciEnd,runFibonacci'
]
ports[1] = ['emitEvent', 'test,outbound,fireEvent,eventFired,emitEvent']
return ports
}

export function mlOpsLoad (kv: string[][]): string[][] {
return [['mlOpsLoad', 'ran']]
}

export function mlOpsTrain (kv: string[][]): string[][] {
return [['mlOpsTrain', 'ran']]
export function emitEvent(kv: string[][]): string[][] {
return [['status', 'ok']]
}

export function getCommands (): string[][] {
export function getCommands(): string[][] {
const commands = new Array<string[]>(2)
commands[0] = ['runFibonacci', 'fibonacci port']
commands[1] = ['deployModule', 'request deployment of a module']
return commands
}

function fibonacci (x: number): number {
if (x === 0) {
return 0
}
if (x === 1) {
return 1
}
function fibonacci(x: number): number {
if (x === 0) return 0
if (x === 1) return 1
return fibonacci(x - 1) + fibonacci(x - 2)
}

export function runFibonacci (kv: string[][]): string[][] {
export function runFibonacci(kv: string[][]): string[][] {
let fibonacciNumber: number = parseInt(findVal('fibonacci', kv))
let startTime: i64 = Date.now()
const sum = fibonacci(fibonacciNumber || 20)
Expand All @@ -95,17 +79,17 @@ export function runFibonacci (kv: string[][]): string[][] {
return rv
}

export function onUpdate (kv: string[][]): string[][] {
export function onUpdate(kv: string[][]): string[][] {
return [['updatedByWasm', new Date(Date.now()).toISOString()]]
}

export function onDelete (kv: string[][]): string[][] {
export function onDelete(kv: string[][]): string[][] {
// return negative to stop the action
//aegis.log('onDelete called')
return [['status', 'ok']]
}

export function validate (kv: string[][]): string[][] {
export function validate(kv: string[][]): string[][] {
//aegis.log('onUpdate called')
return [['status', 'ok']]
}

0 comments on commit 335e9f2

Please # to comment.