Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.2.10 - skipped, released in 0.2.11 #273

Merged
merged 34 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5052022
Update README.md
idanilt Jul 8, 2020
d9b0129
Bump lodash from 4.17.15 to 4.17.19 (#258)
dependabot[bot] Jul 28, 2020
4276f27
bug fixes snapshot + added missing dependency rxjs for @scalecube/api…
idanilt Jul 29, 2020
6e3752e
Addressable post messages. (#259)
idanilt Jul 30, 2020
341ca90
Refactor cluster to use addressable (#261)
idanilt Aug 24, 2020
6f27b8f
transport browser rewrite (#263)
idanilt Aug 29, 2020
31a6a5a
fix lint md
idanilt Aug 29, 2020
e68d2e4
remove lint output
idanilt Aug 29, 2020
669510d
bugfix rsocket-ws-gateway, serviceCall (remote & local): serviceCall …
idanilt Oct 2, 2020
6e3968d
Bump bl from 1.2.2 to 1.2.3 (#268)
dependabot[bot] Nov 16, 2020
e3bf180
Bump bl from 1.2.2 to 1.2.3 in /packages/examples/k8s (#267)
dependabot[bot] Nov 16, 2020
57e22da
fix readme examples (#266)
vpyshnenko Nov 16, 2020
34c2fb9
Bump ini from 1.3.5 to 1.3.8 in /packages/examples/k8s (#271)
dependabot[bot] Dec 25, 2020
d334d8b
Remote registry minimized memory usage + node cluster increase metada…
idanilt Feb 5, 2021
ef62a0f
Fix doc links
idanilt Feb 13, 2021
59f3fa6
Bug fix getAddress util when path empty port swap with path (#275)
idanilt Feb 13, 2021
28aed75
Bump elliptic from 6.5.3 to 6.5.4 (#276)
dependabot[bot] Mar 13, 2021
2715292
Bump ini from 1.3.5 to 1.3.7 (#270)
dependabot[bot] Mar 14, 2021
26eb47f
:rocket: new package rsocket-ws-gateway-client ready for browser (#285)
idanilt May 12, 2021
1bfc66c
Bump ws from 7.3.1 to 7.4.6 (#289)
dependabot[bot] Jul 29, 2021
0bcde3c
Create codeql-analysis.yml
idanilt Jul 29, 2021
49d8de8
Bump browserslist from 4.13.0 to 4.16.6 (#287)
dependabot[bot] Jul 29, 2021
7f48bdc
Update readme (workers and iframe)
idanilt Jul 29, 2021
a931bb3
Bump hosted-git-info from 2.8.8 to 2.8.9 (#283)
dependabot[bot] Jul 29, 2021
f99aa18
Bump lodash from 4.17.19 to 4.17.21 (#282)
dependabot[bot] Jul 29, 2021
a4f9121
Bump ua-parser-js from 0.7.21 to 0.7.28 in /packages/examples/k8s (#281)
dependabot[bot] Jul 29, 2021
0562226
Bump handlebars from 4.7.6 to 4.7.7 (#280)
dependabot[bot] Jul 29, 2021
055eafb
Bump ua-parser-js from 0.7.21 to 0.7.28 (#279)
dependabot[bot] Jul 29, 2021
1fb7075
Bump ssri from 6.0.1 to 6.0.2 (#278)
dependabot[bot] Jul 29, 2021
c38cb83
Bump y18n from 3.2.1 to 3.2.2 (#277)
dependabot[bot] Jul 29, 2021
5ceeff3
Change Alpine image
idanilt Jul 29, 2021
77d932e
exact versions + verify snapshot
idanilt Aug 10, 2021
2deb46e
Use exact same version of @scalecube/* (#294)
idanilt Aug 11, 2021
39ad9e0
Update README.md
idanilt Aug 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
strategy:
matrix:
node-version: [10.x]
timeout-minutes: 30
name: CI
steps:
- uses: actions/checkout@v1
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ develop ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ develop ]
schedule:
- cron: '41 17 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# πŸ“š https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ coverage/
yarn-error.log
.DS_Store
report.html
/packages/addressable/report.cjs.html
/packages/addressable/report.iffe.html
58 changes: 42 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# Scalecube-js

Scalecube is a toolkit for creating microservices/micro-frontends based systems.
[what is scalecube-js](https://idanilt.medium.com/scalecube-js-2785c491ae54) | [play with codesandbox](https://codesandbox.io/s/scalecube-full-tutorial-yjjvu?file=/package.json) | [full documentation](https://scalecube.github.io/javascript-docs)

[![Join the chat at https://gitter.im/scalecube-js/Lobby](https://badges.gitter.im/scalecube-js/Lobby.svg)](https://gitter.im/scalecube-js/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/39bc4219854c4de09abf28a920a474ad)](https://www.codacy.com/app/ido/scalecube-js?utm_source=github.com&utm_medium=referral&utm_content=scalecube/scalecube-js&utm_campaign=Badge_Grade)

> ### Project Status
>
> [Scalecube v0.2.x](https://github.com/scalecube/scalecube-js/issues/30) is stable, the API will be supported until 1.1.2021.
> [Scalecube v0.2.x](https://github.com/scalecube/scalecube-js/issues/30) is stable, the API will be supported until 1.1.2022.
> We want to collect feedback from the community before releasing 1.x.x but we don't foresee any majors API change.
> If you have any feedback please [open issue](https://github.com/scalecube/scalecube-js/issues)

# Scalecube-js

Scalecube is a toolkit for creating microservices/micro-frontends based systems.
[Full documentation](http://scalecube.io/javascript-docs)
> If you have any feedback please [open issue](https://github.com/scalecube/scalecube-js/issues) or talk with us on [gitter](https://gitter.im/scalecube-js/Lobby)

## quick start
> If you are new to scalecube, it's recommended to read [this introduction to scalecube](https://idanilt.medium.com/scalecube-js-2785c491ae54).

We provide browser and NODE templates, configured and ready for use
Scalecube provide browser and NODE templates, configured and ready for use

### [Browser](packages/browser/README.md)

Expand All @@ -33,11 +34,11 @@ import { createMicroservice, ASYNC_MODEL_TYPES } from '@scalecube/node';

### Advanced

You can create your own customized setup, for more details: go to [Microservice](packages/scalecube-microservice/README.md):
You can create your own customized setup, for more details: go to [Microservice](packages/scalecube-microservice/README.md)

### Usage (Browser and node)

**create a seed**
#### create a seed

```typescript
// node - supported WS, WSS and TCP
Expand All @@ -51,7 +52,7 @@ createMicroservice({
});
```

**Create a service**
#### Create a service

```typescript
// Create service definition
Expand All @@ -65,17 +66,17 @@ export const greetingServiceDefinition = {
};
// Create a service
createMicroservice({
service : [{
services : [{
definition: greetingServiceDefinition,
reference: {
hello : (name) => `Hello ${name}`
hello : async (name) => `Hello ${name}`
},
}],
seedAddress : MySeedAddress
});
```

**Use a service**
#### Use a service

```typescript
const microservice = createMicroservice({seedAddress : MySeedAddress})
Expand All @@ -94,7 +95,32 @@ In the browser we don't need to import modules, we can create multiple bundles,

**\*NOTICE** For Node you have to set addresses, there isn't any default at the moment

**Dependency Injection**
#### Worker, Iframes and seperate bundles

You can use scalecube with multiple bundles even inside iframes and *Web Workers, scalecube will be able to find and invoke the services by the address and seedAddress (via Post Messages).

**\*NOTICE** In order to use Web Workers you need to load scalecube before loading the Web Worker (scalecube extends Worker class)

**Good**
```typescript
import from "@scalecube/browser";

new Worker(`assets/worker.js`, {
type: "module"
});
```

**Bad**
```typescript
new Worker(`assets/worker.js`, {
type: "module"
});
```


#### Dependency Injection
You can pass a function instead of object as the reference, this function get `createProxy` and `createServiceCall`, which can help you invoke any service in the cluster. The function need to return object with all the service methods (`[methodName]: function()`).
In the example bellow, we are creating a new instance of a class, but you can do in anyway you want.

```typescript
createMicroservice({
Expand All @@ -112,7 +138,7 @@ createMicroservice({
})
```

For more examples go to [examples](packages/examples) or [full documentation](http://scalecube.io/javascript-docs)
For more examples go to [examples](packages/examples) or [full documentation](https://scalecube.github.io/javascript-docs)

## Scalecube tools

Expand Down
7 changes: 6 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"npmClient": "yarn",
"useWorkspaces": true,
"packages": ["packages/*"],
"version": "0.2.9"
"command": {
"version": {
"exact": true
}
},
"version": "0.2.10"
}
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
"start": "http-server -a localhost -p 8000",
"start-node-example": "lerna run start-node-example",
"bootstrap": "lerna bootstrap --npm-client=yarn",
"build": "lerna run build",
"test": "lerna run test",
"build": "lerna run --stream --concurrency 1 build",
"clean": "lerna run clean --stream",
"test": "lerna run test --stream",
"test-dom-env": "lerna run test-dom-env",
"test-node-env": "lerna run test-node-env",
"lint": "remark . --output && lerna run lint",
"lint": "remark . -f && lerna run lint",
"bumb": "lerna version --no-push --force-publish",
"doc": "lerna run doc"
},
Expand All @@ -48,9 +49,9 @@
"lerna": "^3.13.1",
"prettier": "^1.16.4",
"pretty-quick": "^1.10.0",
"remark-cli": "^6.0.1",
"remark-lint": "^6.0.4",
"remark-preset-lint-recommended": "^3.0.2",
"remark-cli": "^8.0.1",
"remark-lint": "^7.0.1",
"remark-preset-lint-recommended": "^4.0.1",
"rimraf": "^2.6.3",
"tslint-config-prettier": "^1.17.0"
}
Expand Down
63 changes: 63 additions & 0 deletions packages/addressable/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Addressable

A lightweight standalone micro lib to create addressable post messages.
Let say you have some post messages on the main thread a couple of IFrames and a few web workers.
Sending message between this element will be a nightmare!

The solution, **addresses** like a plan tcp/ip network, or the WEB

- This package is independent it maintained under scalecube-js only for convenience.

## TODO

Handle address collusion

# API

Add thread to network; you must add it to main thread in order iframe/workers will work

```ts
import '@scalecube/addressable';
```

listen for messages on address

```ts
import {listen} from '@scalecube/addressable';
listen("address", (msg, port: MessagePort)=>{port.postMessage("pong")});
```

connect to address

```ts
import {connect} from '@scalecube/addressable';
const port = connect("address");
port.addEventListener("message", console.log);
port.postMessage("ping");
```

Cleaning connections

```ts
import {connect, listen} from '@scalecube/addressable';
listen("address", (msg, port: MessagePort) => {
if( msg === "ping" ) {
port.postMessage("pong");
} else if (msg === "close") {
port.close();
}
});

const port = connect("address");
port.addEventListener("message", console.log);
port.postMessage("ping");
port.postMessage("close");
port.close();
```

# How it's works

- Each time you import addressable it will create global event listener in each thread
- Threads will register them self by sending a message to main thread
- Each time new listener added it will spread to main thread and to all thread from there
- When connect is called it will create a message channel and give a port to listen callback and open side
3 changes: 3 additions & 0 deletions packages/addressable/e2eSetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('./e2eStart');

module.exports = require('jest-environment-puppeteer').setup;
7 changes: 7 additions & 0 deletions packages/addressable/e2eStart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { exec } = require('child_process');

const start = exec('yarn start', { cwd: '../../' });

module.exports = {
start,
};
3 changes: 3 additions & 0 deletions packages/addressable/e2eTeardown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const p = require('./e2eStart');
p.start.kill('SIGQUIT');
module.exports = require('jest-environment-puppeteer').teardown;
6 changes: 6 additions & 0 deletions packages/addressable/jest-puppeteer.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
testRegex: '(\\.|/)browser\\.ts$',
preset: 'jest-puppeteer',
globalSetup: './e2eSetup.js',
globalTeardown: './e2eTeardown.js',
};
13 changes: 13 additions & 0 deletions packages/addressable/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
transform: {
'.(ts|tsx)': 'ts-jest',
},
testRegex: '(\\.|/)spec\\.ts$',
testPathIgnorePatterns: ['<rootDir>/es/', '<rootDir>/lib/', '<rootDir>/node_modules/'],
moduleFileExtensions: ['ts', 'tsx', 'js'],
moduleDirectories: ['node_modules', 'src'],
globals: {
isNodeEvn: false,
},
setupFilesAfterEnv: ['<rootDir>/tests/messageChannelMock.ts'],
};
55 changes: 55 additions & 0 deletions packages/addressable/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "@scalecube/addressable",
"version": "0.2.10",
"private": false,
"unpkg": "dist/index.js",
"main": "lib/index.js",
"module": "es/index.js",
"types": "lib/index.d.ts",
"files": [
"lib",
"dist",
"es"
],
"license": "MIT",
"scripts": {
"clean": "rimraf node_modules && rimraf .cache && rimraf lib && rimraf es",
"build": "rimraf .cache && tsc && yarn build:dist && yarn build:cjs",
"build:dist": "rimraf dist && rollup -c rollup.iife.config.js",
"build:cjs": "rimraf lib && rollup -c rollup.cjs.config.js",
"fixture": "yarn build && yarn fixture:build",
"fixture:build": "rimraf tests/fixtures/pingPong/dist && parcel build tests/fixtures/pingPong/pingPong.ts --no-source-maps --experimental-scope-hoisting --out-dir tests/fixtures/pingPong/dist",
"lint": "tslint '{src,tests}/**/*.{ts,tsx}' --fix",
"prettier": "prettier --write '{src,tests}/**/*.{ts,tsx}'",
"test": "yarn test:unit && yarn test:browser",
"test:unit": "jest --config jest.config.js",
"test:browser": "yarn fixture && jest --forceExit --config jest-puppeteer.config.js",
"doc": "typedoc ./src --out ./doc --mode file --name 'Scalecube API' --hideGenerator --readme ./README.md"
},
"author": "Scalecube (https://github.com/scalecube/scalecube-js)",
"dependencies": {
"@babel/plugin-transform-runtime": "^7.11.0"
},
"devDependencies": {
"@rollup/plugin-typescript": "^5.0.2",
"@scalecube/utils": "0.2.10",
"@types/expect-puppeteer": "^4.4.3",
"@types/jest-environment-puppeteer": "^4.3.2",
"@types/puppeteer": "^3.0.1",
"jest-puppeteer": "^4.4.0",
"puppeteer": "^5.2.1",
"rollup": "^1.27.4",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-filesize": "^6.1.1",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-uglify-es": "^0.0.1",
"rollup-plugin-visualizer": "^2.6.0",
"tslint": "^5.11.0",
"typedoc": "^0.14.2",
"typescript": "^3.2.4"
}
}
Loading