open-index/open-npm huggingface dataset:
npm package: @ksfcore/deploy
Description: KSF 框架服务打包工具
Latest version: 2.1.0

# @ksfcore/deploy

KSF framework service packaging tool for packaging services to generate release packages suitable for KSF framework.

## Installation

`npm install -g @ksfcore/deploy`

> `Ksf-deploy` is a CLI program, so you need to use the __- g__ parameter to install

## Usage

`ksf-deploy name [options]`

* name is the "service name" of the service, if your service name is Server, then fill in "Server"
* [options] Optional configuration, see [Options] (# options) section

__When packaging: please change the current directory to the root directory of the service (that is, the directory where the service `package.json` is located) and execute this program

## options

Options:

> -h, --help output usage information  
> -V, --version output the version number  
> -f, --force Force to Build Package  
> -p --platform build deploy package for target platform

### -f, --force

Because the tool will package the current running environment (such as node executable binaries, recompile C / C ++ addon on the current architecture, etc.), please execute the packaging tool on the same environment (linux) as the target operating architecture.

Turn this switch on to bypass this restriction. But at the same time we strongly advise you not to do this!

### -p, --platform
By default, the tool will build package running on the linux platform. If you want to specify other platforms, you can pass this parameter. Currently darwin / linux are supported.

When you package on a non-linux system and do not specify a target platform, we provide a default linux platform nodejs  execution file  (currently linux x64 v12.17). If you want to package your own nodejs execution file, please run this tool in the environment of the target nodejs.
npm package: @ksfcore/dyeing
Description: KSF 染色基础模块
Latest version: 2.0.1

# @ ksf / dyeing

The KSF dyeing basic module provides methods for obtaining and judging `staining objects`.

__Users: You should not use this module directly, but use other modules that meet the `staining standards` to obtain` staining objects`__

__Module developer: Get `KSF stained objects` You should use this module's `gen()` method to get` colored objects`__

## Dyeing (Introduction)

Coloring is a state passed on the interface's invocation chain (server <==> client) to identify a specific request processing process.

This state consists of a flag and additional information `KEY` _ (optional) _.

Services on the call chain can set (originate) and read (receive) this state, and perform corresponding processing (such as outputting specific logs and characteristics).

In the system, dyeing consists of this module and its corresponding convention.

## Standard (Convention)

If the module uses a dyeing system, it is necessary to comply with the following conventions (At the same time, we will refer to the modules that meet the conventions as the modules that meet the `staining standards`):

1. Provide the `getDyeingObj()` method and return `Dyeing Object`.
2. Use the @ ksf/dyeing.gen method to generate a dyeing object.
3. Use the @ ksf/dyeing.is() method to determine whether the dyeing object is valid.

## Module method

### KsfDyeing.gen (dyeing [, key, args])

By calling this method, you can get `colored objects`:

__dyeing__: Do you need dyeing
__key__: Coloring additional information `KEY` (optional)
__args__: additional parameters of the program (optional)

`key` is passed to the next service through the call chain, while `args` is only valid in the current dyed object (it is not passed).

__Please note: The cause of the staining is different from the cause of the staining (thing). This module only cares about the stained objects, not the cause of the staining.__

### KsfDyeing.is(obj)

Call this method to determine whether an object passed in is a `colored object`:

If an empty object is passed in, the method will also return `false`

## Dyeing Object Properties

### dyeingObj.dyeing

Whether coloring is required, this is `Boolean`

### dyeingObj.key

Additional information passed by the dye, this is `String` and is optional and may not exist

### dyeingObj.args

Additional information about the dyed object itself, which should not be passed between services by business code (only used as a local parameter).

This object is not limited in type and is also optional
npm package: @ksfcore/kedis-helper
Description: Kedis调用nodejs实现
Latest version: 2.0.6

## 说明

Kedis是一个基于KSF框架开发的分布式NoSQL存储系统，数据采用内存存储，支持连接后端DB实现数据持久化。Kedis采用集群模式，具有高扩展、高可用的特点。

@ksfcore/kedis-helper是Kedis调用的nodejs实现。

同时从`2.1.0`版本开始，不再依赖Q模块，而使用原生Promise.

> $ npm i @ksfcore/kedis-helper

## 初始化

``` js
const Kedis = require('@ksfcore/kedis-helper')
const kedisProxy = new Kedis({
  proxy: 'Kedis.ADProxyServer.ProxyObj',
  moduleName: 'ADUserProfile'
})

```
> 只需要在对应的proxy添加ip端口既可以实现通过代理方式访问

``` js
const kedisProxy = new Kedis({
  proxy: 'Kedis.ADProxyServer.ProxyObj@tcp -h 172.16.8.125 -p 8888 -t 6000',
  moduleName: 'ADUserProfile'
})

```

默认情况下，Kedis的rpc调用保持长连接，即每20秒会给服务端发送一个心跳，如果不想保持长连接，可以通过设置keepAlive为false来实现，例如：
``` js
const kedisProxy = new Kedis({
  keepAlive: false,
  proxy: 'Kedis.ADProxyServer.ProxyObj',
  moduleName: 'ADUserProfile'
})
```

## 调用
Kedis相关数据结构请参照 `CacheShare.jce` 和 `ProxyShare.jce`，对应的js对象分别为 `cacheShareProxy` 和 `proxyShareProxy`
```js
const { cacheShareProxy, proxyShareProxy } = require('@ksfcore/kedis-helper')
```

Kedis调用API请参照 `Proxy.jce`，下例将给出多个DEMO

```js
const KsfStream = require("@ksfcore/stream")
const Kedis = require('@ksfcore/kedis-helper')
const { cacheShareProxy, proxyShareProxy } = Kedis

const kedisProxy = new Kedis({
  proxy: 'Kedis.ADProxyServer.ProxyObj@tcp -h 172.16.8.125 -p 8888 -t 6000',
  moduleName: 'ADUserProfile'
})

// 单次不带版本调用
kedisProxy.getString('testKey').then.then(console.log).catch(console.error);

// 单次不带版本写入
kedisProxy.setString('testKey', 'testValue').then(console.log).catch(console.error);


// 批量查询全量数据
const vec = new KsfStream.List(KsfStream.String)
vec.readFromObject(['testKey1', 'testKey2'])
kedisProxy.getKVBatch(vec).then(console.log).catch(console.error)
//...

```

## 指定master
如下列举两种服务调用方式：
### 1.http server
自由传递context上下文，参照如下`http`demo

```js
const KsfStream = require('@ksfcore/stream')
const kedisProxy = new Kedis({
  proxy: 'Kedis.ADProxyServer.ProxyObj',
  moduleName: 'ADUserProfile',
})

const context = new KsfStream.Map(KsfStream.String, KsfStream.String)
context.insert('idcAreaSpecified', 'force-master')
// http server or other environment
kedisProxy.getKV('a', { context }).then(console.log).catch(console.error)
```
### 2.ksf server
`ksf server` 从当前服务的上下文中获取上下文，并进行传递
当然也支持自己构造context上下文方式(`参照上述hhtp方式`)
```js
// ksf server
CRM.TestImp.prototype.test = async function (current, req, rsp) {

  // ...

  //////////// 透传context DEMO start ////////
  const context = current.getContext();
  context.insert('idcAreaSpecified', 'force-master')

  kedisProxy.getString('a', { context }).then(console.log).catch(console.error);

  //////////// 透传context DEMO end ////////

  // ...
}
```