npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

flume_client_sdk

v1.0.0

Published

flume client sdk

Readme

日志中间件

如何使用

LogMaker.init(callback)即为初始化完成的回调,LogMaker需要去读取配置和初始化客户端,初始化完成后可在外面调用

var LogMaker = require('../index');
LogMaker.init({'host': '106.75.98.19:2181', 'path': '/h5_flume/config', 'client_path': '/h5_flume/h5_out_net'}, function () {
    // 初始化完成后才可调用
    LogMaker.log_coin(1003, 1, 'role_id', 'field_name', 0, 100, 1, 'scene', 'remark', new Date().toLocaleString(), '');
    LogMaker.log_login(1003, 9, 9, 'user_id', 'role_id', 'device_os', 'device_type', 'device_id', 1, 1, 'ip', null, '');
    LogMaker.log_register(1003, 9, 9, 'user_id', 'role_id', 'device_os', 'device_type', 'device_id', null, '');
    LogMaker.log_adv(1003, 9, 'device_id', new Date().toLocaleString(), '');
    LogMaker.log_tran(order_id, 'cp_user_id', 1003, 'sp_order_id', 'sp_user_id', 0, 1003, 9,
        'device_id', 'role_id', 'role_name', 0, 1, 'product_id', 1.00, 'remark', 1, new Date().toLocaleString());
});

释放资源
LogMaker.release()

目录说明

.
├── gen-nodejs      			 # flume生成的类,通过thrift协议收集日志
├── logs      			     # 本地日志
├── model      			     # 接口类
├── test      			     # 测试类
│   ├── test_client        # 测试客户端可用性
│   ├── test_index     # 测试中间件整体的可用性
│   ├── test_zookeeper     # 测试zk集群的可用性
├── utils      			     # 工具封装
│   ├── client_util        # 客户端封装,创建、提供可用客户端、错误重连
│   ├── config             # 读取zookeeper集群配置及监听
│   ├── file_util          # 发送错误时写入文件和读取再次发送
│   ├── timer_util         # 定时读取发送失败的日志重发
├── index                 # 对外提供接口
├── package.json              # 依赖包

接入遇到常见问题:

  1. 传送过来的参数类型,是否正确,如果不正确会导致不能正常写入数据库。
  2. 发送测试消息每次要不一样,一样的话会被去重,导致不能写入数据库。

部分接口特别说明

| 字段名 | 描述 | 类型 | | -------------- | -------------------------- | --------- | | cp_app_id | 应用标识:100325 | int | | retail_id | 渠道标识,从1000起自由定义 | int | | game_id | 10001 | int | | device_id | 设备标识,获取不到传"" | string | | field_name | 付费:pay_gold, 免费: free_gold | string | | activated_time | 所有时间相关格式统一如"2017-8-30 17:36:13" | TIMESTAMP | | lifetime | 消费周期,如月卡30,年卡365 | int | | uptime | 从角色登录到退出的时间,没有传0 | int | | sp_order_id | 第三方的order_id | string | | pay_id | 1支付宝,2微信,获取不到传0 | int | | order_time | 订单生成时间、订单成功交易时间 | TIMESTAMP | | currency_id | RMB:1 | SMALLINT |

广告日志

| 字段名 | 描述 | 类型 | | -------------- | --------- | ----------- | | cp_app_id | 内容提供商应用标识 | INT | | retail_id | 渠道标识 | INT | | device_id | 设备标识 | VARCHAR(64) | | activated_time | 注册时间 | TIMESTAMP | | reserve | 保留字段 | TEXT |

虚拟币日志

  • 充值RMB时获取的虚拟币日志,充值和消费都需要记录

| 字段名 | 描述 | 类型 | | ---------- | --------- | ------ | | cp_app_id | 内容提供商应用标识 | int | | server_id | 区服标识 | int | | role_id | 角色标识 | string | | field_name | 虚拟币字段名称 | string | | old_val | 原始值 | int | | new_val | 目标值 | int | | lifetime | 消费周期 | int | | scene | 数值变化场景 | string | | remark | 备注 | string | | log_time | 日志时间(可选) | string | | reserve | 保留字段(可选) | string |

登录日志

  • 登录账号不发,登录角色发

| 字段名 | 描述 | 类型 | | ----------- | ------------- | ----------- | | cp_app_id | 内容提供商应用标识 | INT | | server_id | 区服标识 | INT | | retail_id | 渠道标识 | INT | | user_id | 用户标识 | VARCHAR(36) | | role_id | 角色标识 | VARCHAR(32) | | device_id | 设备标识 | VARCHAR(64) | | device_type | 设备类型 | VARCHAR(64) | | device_os | 设备系统 | VARCHAR(32) | | uptime | 在线时长,从登陆开始的秒数 | INT | | lvl | 角色等级 | INT | | ip | 登录地址 | VARCHAR(64) | | log_time | 日志时间(可选) | string | | reserve | 保留字段(可选) | TEXT |

注册日志

  • 注册账号不发,注册角色发

| 字段名 | 描述 | 类型 | | ----------- | --------- | ----------- | | cp_app_id | 内容提供商应用标识 | INT | | server_id | 区服标识 | INT | | retail_id | 渠道标识 | INT | | role_id | 角色标识 | VARCHAR(32) | | user_id | 用户标识 | VARCHAR(32) | | device_id | 设备标识 | VARCHAR(64) | | device_type | 设备类型 | VARCHAR(64) | | device_os | 设备系统 | VARCHAR(32) | | log_time | 日志时间(可选) | string | | reserve | 保留字段(可选) | TEXT |

订单日志

  • 生成订单发一次,交易成功发一次

| 字段名 | 描述 | 类型 | | ----------- | --------------- | ------------- | | cp_order_id | 内容提供商订单标识 | VARCHAR(36) | | cp_user_id | 内容提供商用户标识 | VARCHAR(32) | | cp_app_id | 内容提供商应用标识 | INT | | sp_order_id | 服务提供商订单标识 | VARCHAR(127) | | sp_user_id | 服务提供商用户标识 | VARCHAR(64) | | game_id | 游戏标识 | INT | | server_id | 区服标识 | INT | | retail_id | 渠道标识 | INT | | device_id | 设备标识 | VARCHAR(64) | | role_id | 角色标识 | VARCHAR(32) | | role_name | 角色名称 | VARCHAR(32) | | pay_id | 用户支付方式标识 | SMALLINT | | order_time | 订单时间 | TIMESTAMP | | currency_id | 币种 | SMALLINT | | product_id | 购买项标识 | VARCHAR(64) | | amount | 充值金额 | DECIMAL(10,2) | | remark | 备注 | TEXT | | is_success | 订单同步状态(1成功,0失败) | INT | | reserve | 保留字段(可选) | TEXT |