<commit_before>package server

import (
	"encoding/json"
	"os"
	"runtime"

	rpc_tendermint "github.com/eris-ltd/eris-db/rpc/tendermint"
	"github.com/eris-ltd/eris-db/server"
	"github.com/gin-gonic/gin"
	"github.com/tendermint/log15"
)

func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	log15.Root().SetHandler(log15.LvlFilterHandler(
		log15.LvlWarn,
		log15.StreamHandler(os.Stdout, log15.TerminalFormat()),
	))
	gin.SetMode(gin.ReleaseMode)
}

type ScumbagServer struct {
	running bool
}

func NewScumbagServer() server.Server {
	return &ScumbagServer{}
}

func (this *ScumbagServer) Start(sc *server.ServerConfig, g *gin.Engine) {
	g.GET("/scumbag", func(c *gin.Context) {
		c.String(200, "Scumbag")
	})
	this.running = true
}

func (this *ScumbagServer) Running() bool {
	return this.running
}

func (this *ScumbagServer) ShutDown() {
	// fmt.Println("Scumbag...")
}

type ScumSocketService struct{}

func (this *ScumSocketService) Process(data []byte, session *server.WSSession) {
	resp := rpc_tendermint.NewRPCResponse("1", "Scumbag")
	bts, _ := json.Marshal(resp)
	session.Write(bts)
}

func NewScumsocketServer(maxConnections uint16) *server.WebSocketServer {
	sss := &ScumSocketService{}
	return server.NewWebSocketServer(maxConnections, sss)
}

func NewServeScumbag() (*server.ServeProcess, error) {
	cfg := server.DefaultServerConfig()
	cfg.Bind.Port = uint16(31400)
	return server.NewServeProcess(cfg, NewScumbagServer())
}

func NewServeScumSocket(wsServer *server.WebSocketServer) (*server.ServeProcess,
	error) {
	cfg := server.DefaultServerConfig()
	cfg.WebSocket.WebSocketEndpoint = "/scumsocket"
	cfg.Bind.Port = uint16(31401)
	return server.NewServeProcess(cfg, wsServer)
}<commit_msg>test: also move rpc definition of RpcRequest and RpcResponse for scumbag server test<commit_after>package server

import (
	"encoding/json"
	"os"
	"runtime"

	rpc "github.com/eris-ltd/eris-db/rpc"
	"github.com/eris-ltd/eris-db/server"
	"github.com/gin-gonic/gin"
	"github.com/tendermint/log15"
)

func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	log15.Root().SetHandler(log15.LvlFilterHandler(
		log15.LvlWarn,
		log15.StreamHandler(os.Stdout, log15.TerminalFormat()),
	))
	gin.SetMode(gin.ReleaseMode)
}

type ScumbagServer struct {
	running bool
}

func NewScumbagServer() server.Server {
	return &ScumbagServer{}
}

func (this *ScumbagServer) Start(sc *server.ServerConfig, g *gin.Engine) {
	g.GET("/scumbag", func(c *gin.Context) {
		c.String(200, "Scumbag")
	})
	this.running = true
}

func (this *ScumbagServer) Running() bool {
	return this.running
}

func (this *ScumbagServer) ShutDown() {
	// fmt.Println("Scumbag...")
}

type ScumSocketService struct{}

func (this *ScumSocketService) Process(data []byte, session *server.WSSession) {
	resp := rpc.NewRPCResponse("1", "Scumbag")
	bts, _ := json.Marshal(resp)
	session.Write(bts)
}

func NewScumsocketServer(maxConnections uint16) *server.WebSocketServer {
	sss := &ScumSocketService{}
	return server.NewWebSocketServer(maxConnections, sss)
}

func NewServeScumbag() (*server.ServeProcess, error) {
	cfg := server.DefaultServerConfig()
	cfg.Bind.Port = uint16(31400)
	return server.NewServeProcess(cfg, NewScumbagServer())
}

func NewServeScumSocket(wsServer *server.WebSocketServer) (*server.ServeProcess,
	error) {
	cfg := server.DefaultServerConfig()
	cfg.WebSocket.WebSocketEndpoint = "/scumsocket"
	cfg.Bind.Port = uint16(31401)
	return server.NewServeProcess(cfg, wsServer)
}
{'fraction_non_alphanumeric': 0.1425260718424102, 'fraction_numerical': 0.01853997682502897, 'mean_word_length': 5.564638783269962, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1423061', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1304, 'n_words': 222}