Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/vjeantet/bitfan
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeantet committed Dec 4, 2017
2 parents 6ef9e00 + f2c6e58 commit 406139e
Show file tree
Hide file tree
Showing 1,099 changed files with 214,735 additions and 23,712 deletions.
28 changes: 27 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ _testmain.go

tester
examples.d/twitter.conf
bitfan

releases
.DS_Store

Expand All @@ -42,3 +42,29 @@ releases
/docs/public/

/docs/themes/hugo-theme-docdock

/.vscode/

*.coverprofile

*.css.map

.sass-cache

/ui/cmd/oo

/ui/cmd/test.db

/webui/webui

/dist/

/cmd/bitfan/.bitfan/

/cmd/bitfan/notes.md

/.idea/

/coverage.txt

/codecovRepport.sh
33 changes: 33 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# .goreleaser.yml
# Build customization
builds:
- binary: bitfan
main: ./cmd/bitfan/main.go
goos:
- windows
- darwin
- linux
goarch:
- amd64
- arm
goarm:
- 7
- binary: bitfanUI
main: ./cmd/bitfanUI/main.go
goos:
- windows
- darwin
- linux
goarch:
- amd64
- arm
goarm:
- 7
# Archive customization
archive:
format: tar.gz
format_overrides:
- goos: windows
format: zip
replacements:
darwin: macOS
15 changes: 11 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
language: go

# before_cache:
# - find $GOPATH/pkg/**/github.com/vjeantet/bitfan/* -maxdepth 0 ! -name vendor -print0 | xargs -0 rm -rf
#
# cache:
# directories:
# - $GOPATH/pkg

install:
- go get -v golang.org/x/tools/cmd/cover
- go get -v github.com/stretchr/testify/assert
script:
- go test -v -tags=testcgo -covermode=count -coverprofile=profile.cov
- ./go.test.sh
after_success:
- go get -v github.com/mattn/goveralls
- export PATH=$PATH:$HOME/gopath/bin
- goveralls -coverprofile=profile.cov -service=travis-ci
- bash <(curl -s https://codecov.io/bash)
- test -n "$TRAVIS_TAG" && go get github.com/goreleaser/goreleaser && goreleaser --skip-validate
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
# Bitfan

Bitfan is an open source data processing pipeline really inspired by Logstash.

Bitfan is written in Go and should build on all platforms.

![Bitfan logo](docs/static/noun_307496_cc.png "Bitfan")
<h1 align="center">
<a href="https://bitfan.io"><img src="docs/static/open-fan-black-medium.png" height="150px" alt="Bitfan"></a>
<br>
Bitfan
</h1>

<h4 align="center">Data and Event processing pipeliner really inspired by Logstash.</h4>

<p align="center">
<a href="https://godoc.org/github.com/vjeantet/bitfan">
<img src="https://godoc.org/github.com/vjeantet/bitfan?status.svg" alt="GoDoc" style="max-width:100%;">
</a>
<a href="https://goreportcard.com/report/github.com/vjeantet/bitfan">
<img src="https://goreportcard.com/badge/github.com/vjeantet/bitfan" alt="Go Report Card" style="max-width:100%;">
</a>
<a href="https://travis-ci.org/vjeantet/bitfan">
<img src="https://travis-ci.org/vjeantet/bitfan.svg?branch=master" alt="Build Status" style="max-width:100%;">
</a>
<a href="https://codecov.io/gh/vjeantet/bitfan">
<img src="https://codecov.io/gh/vjeantet/bitfan/branch/master/graph/badge.svg" alt="Codecov" />
</a>
</p>

---

# Get bitfan, usage and configuration documentation and a availables processors

Expand All @@ -21,13 +38,10 @@ Bitfan is written in Go and should build on all platforms.
- [x] install bitfan as a system daemon / service
- [x] manage running pipelines (list / stop / start a pipeline in a running bitfan)
- [x] monitor pipeline processors and events with prometheus
- [ ] REST API to manage Bitfan (WIP)
- [x] REST API to manage Bitfan
- [x] WebUI

# Badges

[![GoDoc](https://godoc.org/github.com/vjeantet/bitfan?status.svg)](https://godoc.org/github.com/vjeantet/bitfan)
[![Go Report Card](https://goreportcard.com/badge/github.com/vjeantet/bitfan)](https://goreportcard.com/report/github.com/vjeantet/bitfan)
[![Build Status](https://travis-ci.org/vjeantet/bitfan.svg?branch=master)](https://travis-ci.org/vjeantet/bitfan)


# Similar projets in go
Expand All @@ -38,7 +52,7 @@ Bitfan is written in Go and should build on all platforms.
* spartanlogs/spartan - Spartan is a data process much like Logstash

# Credits
logo "hand fan" by lastspark from the Noun Project
Icon made by [Freepik](http://www.freepik.com) from [www.flaticon.com](https://www.flaticon.com/) is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/)

# Contributors
* @vjeantet - Valere JEANTET
Expand Down
6 changes: 0 additions & 6 deletions api/README.md

This file was deleted.

7 changes: 7 additions & 0 deletions api/api_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package api

import "testing"

func TestAPI(t *testing.T) {
t.Skip("TODO")
}
154 changes: 154 additions & 0 deletions api/assets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package api

import (
"bytes"
"fmt"
"net/http"

"github.com/gin-gonic/gin"
uuid "github.com/nu7hatch/gouuid"
"github.com/vjeantet/bitfan/core"
"github.com/vjeantet/bitfan/api/models"
"github.com/vjeantet/bitfan/entrypoint/parser/logstash"
)

type AssetApiController struct {
path string
}

func (a *AssetApiController) CheckSyntax(c *gin.Context) {
var asset models.Asset
uuid := c.Param("uuid")
asset.Uuid = uuid
err := c.BindJSON(&asset)
if err != nil {
c.JSON(500, models.Error{Message: err.Error()})
return
}

_, err = logstash.NewParser(bytes.NewReader(asset.Value)).Parse()
if err != nil {
c.JSON(200, gin.H{
"l": err.(*logstash.ParseError).Line,
"c": err.(*logstash.ParseError).Column,
"uuid": asset.Uuid,
"m": err.(*logstash.ParseError).Reason,
})
} else {
c.JSON(200, gin.H{
"uuid": asset.Uuid,
"m": "ok",
})
}

}

func (a *AssetApiController) Create(c *gin.Context) {
var asset models.Asset
err := c.BindJSON(&asset)
if err != nil {
c.JSON(500, models.Error{Message: err.Error()})
return
}

uid, _ := uuid.NewV4()
asset.Uuid = uid.String()
asset.Size = len(asset.Value)

n := 512
if len(asset.Value) < 512 {
n = len(asset.Value)
}
asset.ContentType = http.DetectContentType(asset.Value[:n])

core.Storage().CreateAsset(&asset)

c.Redirect(302, fmt.Sprintf("/%s/assets/%s", a.path, asset.Uuid))
}

func (a *AssetApiController) FindOneByUUID(c *gin.Context) {
uuid := c.Param("uuid")

asset, err := core.Storage().FindOneAssetByUUID(uuid)
if err != nil {
c.JSON(404, models.Error{Message: err.Error()})
return
}

c.JSON(200, asset)
}

func (a *AssetApiController) DownloadOneByUUID(c *gin.Context) {
uuid := c.Param("uuid")

asset, err := core.Storage().FindOneAssetByUUID(uuid)
if err != nil {
c.JSON(404, models.Error{Message: err.Error()})
return
}

c.Header("Content-Disposition", "attachment; filename=\""+asset.Name+"\"")
c.Data(200, "application/octet-stream", asset.Value)
}

func (a *AssetApiController) UpdateByUUID(c *gin.Context) {
uuid := c.Param("uuid")
asset, err := core.Storage().FindOneAssetByUUID(uuid)
if err != nil {
c.JSON(404, models.Error{Message: err.Error()})
return
}

err = c.BindJSON(&asset)
if err != nil {
c.JSON(500, models.Error{Message: err.Error()})
return
}

core.Storage().SaveAsset(&asset)

c.Redirect(302, fmt.Sprintf("/%s/assets/%s", a.path, asset.Uuid))
}

func (a *AssetApiController) DeleteByUUID(c *gin.Context) {
uuid := c.Param("uuid")

asset, err := core.Storage().FindOneAssetByUUID(uuid)
if err != nil {
c.JSON(404, models.Error{Message: err.Error()})
return
}

core.Storage().DeleteAsset(&asset)

c.JSON(204, "")
}

func (a *AssetApiController) ReplaceByUUID(c *gin.Context) {
uuid := c.Param("uuid")
asset, err := core.Storage().FindOneAssetByUUID(uuid)
if err != nil {
c.JSON(404, models.Error{Message: err.Error()})
return
}

tmpasset := models.Asset{}
err = c.BindJSON(&tmpasset)
if err != nil {
c.JSON(500, models.Error{Message: err.Error()})
return
}

asset.Name = tmpasset.Name
asset.Value = tmpasset.Value
asset.Size = len(asset.Value)
n := 512
if len(asset.Value) < 512 {
n = len(asset.Value)
}
asset.ContentType = http.DetectContentType(asset.Value[:n])

core.Storage().SaveAsset(&asset)

c.Redirect(302, fmt.Sprintf("/%s/assets/%s", a.path, asset.Uuid))
}

0 comments on commit 406139e

Please sign in to comment.