---
title: "simple_flow一个简单的流式计算框架 "
author: "finallygo"
date: "2014-10-29T11:24:38Z"
tags: []
categories: ["开源软件"]
slug: "simple-flow"
draft: false
lastmod: "2014-10-29T11:24:38Z"
id: 2149175
url: "https://finallygo.iteye.com/blog/2149175"
---

# simple\_flow

simple realtime flow computation

## [](https://github.com/hongliuliao/simple_flow/blob/master/README.md#%E7%AE%80%E4%BB%8B)简介

simple\_flow 是一个简单的实时流计算框架,由两部分组成,一个是agent,一个是flow\_server, agent负责将数据实时传输给flow\_server,flow\_server负责对实时流的处理

## [](https://github.com/hongliuliao/simple_flow/blob/master/README.md#%E7%89%B9%E7%82%B9)特点

- linux only
- 继承simple系列的传统,简洁实用
- 安全,可靠 -- 采用拉模式,对数据源系统依赖,影响小

## [](https://github.com/hongliuliao/simple_flow/blob/master/README.md#%E4%BE%9D%E8%B5%96)依赖

- [simple\_log](https://github.com/hongliuliao/simple_log) 日志组件

## [](https://github.com/hongliuliao/simple_flow/blob/master/README.md#%E6%9E%84%E5%BB%BA--%E6%B5%8B%E8%AF%95)构建 && 测试

```
  make && make test # 此步骤会生成一个agent和一个测试用的flow_server
  ./bin/flow_server_test # start flow_server to receive flow
  ./bin/fileagent localhost 3491 /tmp/test.log # usage: ./bin/fileagent flow_server_ip flow_server_port file_path
```

## [](https://github.com/hongliuliao/simple_flow/blob/master/README.md#%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B)代码示例

```
#include <fstream>
#include "simple_log.h"
#include "flow_handler.h"
#include "flow_server.h"

class LogFlowHandler : public FlowHandler {

public:
    int do_handle(char *flow_bytes, int size) {
        std::string receive_flow = std::string(flow_bytes, size);
        LOG_DEBUG("start handle the size:%d, flows %s", size, receive_flow.c_str());
        return 0;
    }
};

int main() {
    FlowServer flow_server;
    flow_server.start(3491, new LogFlowHandler());
    return 1;
}
```

 

  项目地址: [https://github.com/hongliuliao/simple\_flow](https://github.com/hongliuliao/simple_flow)