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

feat(js-sdk): add Node.js SDK #262

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ logs/
/cover.out
vendor/
demo/state/redis/client
node_modules/
sdk/js-sdk/dist
12 changes: 10 additions & 2 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ header:
- 'sdk/'

paths-ignore:
# js related
- 'sdk/js-sdk/node_modules/'
- 'sdk/js-sdk/demo/'
- '**/*.config.js'
- '**/*pb.d.ts'
- '**/*pb.js'
# java related
- 'sdk/java-sdk/sdk/target/'
- '**/*Grpc.java'
- '**/*Proto.java'
- '**/*.json'
- '**/*.log'
- '**/*.log.*'
- '**/*.lst'
- '**/*.pb.go'
- '**/*Grpc.java'
- '**/*Proto.java'
- '**/*.proto'
- '**/*.yaml'
- '**/*.xml'
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ build-linux-wasm-layotto:
docker build --rm -t ${BUILD_IMAGE} build/contrib/builder/image/faas
docker run --rm -v $(shell pwd):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE} go build -tags wasmer -o layotto /go/src/${PROJECT_NAME}/cmd/layotto

license-checker:
docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix

.PHONY: build
211 changes: 211 additions & 0 deletions configs/config_integration_redis_etcd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
{
"servers": [
{
"default_log_path": "stdout",
"default_log_level": "DEBUG",
"routers": [
{
"router_config_name": "http_router",
"virtual_hosts": [
{
"name": "http_host",
"domains": [
"*"
],
"routers": [
{
"match": {
"headers": [
{
"name": "id",
"value": "HelloService:1.0"
}
]
},
"route": {
"cluster_name": "http_server"
}
}
]
}
]
},
{
"router_config_name": "actuator_dont_need_router"
}
],
"listeners": [
{
"name": "grpc",
"address": "127.0.0.1:34904",
"bind_port": true,
"filter_chains": [
{
"filters": [
{
"type": "grpc",
"config": {
"server_name": "runtime",
"grpc_config": {
"rpcs": {
"mosn": {
"config": {
"channel": [
{
"size": 16,
"protocol": "http",
"listener": "egress_runtime_http"
}
]
}
}
},
"hellos": {
"helloworld": {
"hello": "greeting"
}
},
"bindings": {
"http": {
"metadata": {
"url": "https://registry.npmmirror.com/layotto/0.0.0"
}
}
},
"config_stores": {
"etcd": {
"address": [
"127.0.0.1:2379"
],
"timeout": "10"
}
},
"state": {
"redis": {
"metadata": {
"redisHost": "localhost:6380",
"redisPassword": ""
}
}
},
"sequencer": {
"etcd": {
"metadata": {
"endpoints": "localhost:2379",
"segmentCacheEnable": "false",
"segmentStep": "1",
"username": "",
"password": "",
"dialTimeout": "5"
}
},
"redis": {
"metadata": {
"redisHost": "127.0.0.1:6380",
"redisPassword": ""
}
}
},
"lock": {
"etcd": {
"metadata": {
"endpoints": "localhost:2379",
"username": "",
"password": "",
"keyPrefixPath": "/lock",
"dialTimeout": "5"
}
},
"redis": {
"metadata": {
"redisHost": "localhost:6380",
"redisPassword": ""
}
}
},
"pub_subs": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里配置没有生效

"redis": {
"metadata": {
"redisHost": "localhost:6380",
"redisPassword": ""
}
}
},
"app": {
"app_id": "app1",
"grpc_callback_port": 9999
}
}
}
}
]
}
]
},
{
"name": "actuator",
"address": "127.0.0.1:34999",
"bind_port": true,
"filter_chains": [
{
"filters": [
{
"type": "proxy",
"config": {
"downstream_protocol": "Http1",
"upstream_protocol": "Http1",
"router_config_name": "actuator_dont_need_router"
}
}
]
}
],
"stream_filters": [
{
"type": "actuator_filter"
}
]
},
{
"name": "egress_runtime_http",
"type": "egress",
"address": "0.0.0.0:12221",
"bind_port": true,
"network": "tcp",
"filter_chains": [
{
"filters": [
{
"type": "proxy",
"config": {
"downstream_protocol": "Http1",
"name": "proxy_config",
"router_config_name": "http_router",
"upstream_protocol": "Http1"
}
}
]
}
]
}
]
}
],
"cluster_manager": {
"tls_context": {},
"clusters": [
{
"name": "http_server",
"type": "SIMPLE",
"lb_type": "LB_RANDOM",
"hosts": [
{
"address": "127.0.0.1:8889",
"hostname": "downstream_machine1",
"weight": 1
}
]
}
]
}
}
3 changes: 2 additions & 1 deletion demo/configuration/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ package main
import (
"context"
"fmt"
client "mosn.io/layotto/sdk/go-sdk/client"
"time"

client "mosn.io/layotto/sdk/go-sdk/client"
)

func main() {
Expand Down
59 changes: 59 additions & 0 deletions sdk/js-sdk/.github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# Copyright 2021 Layotto Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
schedule:
- cron: '0 2 * * *'

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
node-version: [14, 16]
os: [ubuntu-latest, macos-latest]

steps:
- name: Checkout Git Source
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: npm i -g npminstall && npminstall

- name: Continuous Integration
run: npm run ci

- name: Code Coverage
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
Loading