提交 45939d7f 编写于 作者: Y Your Name

修改初始化sql

上级 e03fea14
...@@ -185,7 +185,7 @@ CREATE TABLE "goku_gateway_api" ( ...@@ -185,7 +185,7 @@ CREATE TABLE "goku_gateway_api" (
"protocol" text(20), "protocol" text(20),
"stripSlash" text(32), "stripSlash" text(32),
"apiType" integer NOT NULL DEFAULT 0, "apiType" integer NOT NULL DEFAULT 0,
"responseDataType" text NOT NULL DEFAULT 'origin', "responseDataType" text NOT NULL DEFAULT origin,
"linkApis" TEXT, "linkApis" TEXT,
"staticResponse" TEXT "staticResponse" TEXT
); );
...@@ -319,27 +319,22 @@ CREATE TABLE "goku_node_group" ( ...@@ -319,27 +319,22 @@ CREATE TABLE "goku_node_group" (
DROP TABLE IF EXISTS "goku_node_info"; DROP TABLE IF EXISTS "goku_node_info";
CREATE TABLE "goku_node_info" ( CREATE TABLE "goku_node_info" (
"nodeID" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "nodeID" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"nodeIP" text(255) NOT NULL,
"updateStatus" integer(4) NOT NULL DEFAULT 0,
"createTime" text, "createTime" text,
"updateTime" text, "updateTime" text,
"groupID" integer(11) NOT NULL DEFAULT 0, "groupID" integer(11) NOT NULL DEFAULT 0,
"nodeName" text(255) NOT NULL, "nodeName" text(255) NOT NULL,
"nodePort" text(255),
"nodeStatus" integer(11) NOT NULL, "nodeStatus" integer(11) NOT NULL,
"version" text(255), "version" text(255),
"sshAddress" text(255) DEFAULT 22, "sshPort" text(255) DEFAULT 22,
"sshUserName" text(255), "userName" text(255),
"sshPassword" text(255), "password" text(255),
"gatewayPath" text(255), "gatewayPath" text(255),
"sshKey" text, "key" text,
"authMethod" integer(4) NOT NULL DEFAULT 0, "authMethod" integer(4) NOT NULL DEFAULT 0,
"clusterID" integer(11) NOT NULL DEFAULT 0, "clusterID" integer(11) NOT NULL DEFAULT 0
"listenAddress" text(22) NOT NULL DEFAULT '',
"adminAddress" text(22) NOT NULL DEFAULT '',
"nodeKey" TEXT(32) NOT NULL DEFAULT ''
);
CREATE UNIQUE INDEX "nodeKey_new"
ON "goku_node_info_new" (
"nodeKey" ASC
); );
-- ---------------------------- -- ----------------------------
...@@ -409,32 +404,6 @@ CREATE TABLE "goku_table_update_record" ( ...@@ -409,32 +404,6 @@ CREATE TABLE "goku_table_update_record" (
"tableID" integer NOT NULL PRIMARY KEY AUTOINCREMENT "tableID" integer NOT NULL PRIMARY KEY AUTOINCREMENT
); );
CREATE TABLE "goku_table_version" (
"tableID" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"tableName" TEXT NOT NULL,
"version" TEXT NOT NULL
);
CREATE UNIQUE INDEX "tableName"
ON "goku_table_version" (
"tableName"
);
INSERT INTO "goku_table_version" ("tableName","version") VALUES ('goku_node_info', "3.1.1");
INSERT INTO "goku_table_version" ("tableName","version") VALUES ('goku_monitor_module', "3.1.1");
CREATE TABLE "goku_monitor_module" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT NOT NULL,
"config" TEXT NOT NULL,
"moduleStatus" integer NOT NULL DEFAULT 0
);
CREATE UNIQUE INDEX "moduleName"
ON "goku_monitor_module" (
"name" ASC
);
-- ---------------------------- -- ----------------------------
-- Records of "sqlite_sequence" -- Records of "sqlite_sequence"
...@@ -458,17 +427,17 @@ UPDATE "sqlite_sequence" SET seq = 1 WHERE name = 'goku_admin'; ...@@ -458,17 +427,17 @@ UPDATE "sqlite_sequence" SET seq = 1 WHERE name = 'goku_admin';
-- Indexes structure for table goku_balance -- Indexes structure for table goku_balance
-- ---------------------------- -- ----------------------------
CREATE INDEX "balanceName" CREATE INDEX "balanceName"
ON "goku_balance" ( ON "goku_balance" (
"balanceName" ASC "balanceName" ASC
); );
-- ---------------------------- -- ----------------------------
-- Indexes structure for table goku_cluster -- Indexes structure for table goku_cluster
-- ---------------------------- -- ----------------------------
CREATE INDEX "name" CREATE INDEX "name"
ON "goku_cluster" ( ON "goku_cluster" (
"name" ASC "name" ASC
); );
-- ---------------------------- -- ----------------------------
-- Auto increment value for goku_config_log -- Auto increment value for goku_config_log
......
...@@ -3,12 +3,14 @@ package application ...@@ -3,12 +3,14 @@ package application
import ( import (
"bytes" "bytes"
"errors" "errors"
"github.com/eolinker/goku-api-gateway/diting"
goku_labels "github.com/eolinker/goku-api-gateway/goku-labels"
"github.com/eolinker/goku-api-gateway/node/monitor"
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
"github.com/eolinker/goku-api-gateway/diting"
goku_labels "github.com/eolinker/goku-api-gateway/goku-labels"
"github.com/eolinker/goku-api-gateway/node/monitor"
// "fmt" // "fmt"
"time" "time"
) )
...@@ -99,16 +101,16 @@ func (r *Request) Send() (*http.Response, error) { ...@@ -99,16 +101,16 @@ func (r *Request) Send() (*http.Response, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
start:=time.Now() start := time.Now()
defer func() { defer func() {
delay:= time.Since(start) delay := time.Since(start)
labels:= make(diting.Labels) labels := make(diting.Labels)
labels[goku_labels.Proto] = req.Proto labels[goku_labels.Proto] = req.Proto
labels[goku_labels.Host] = req.Host labels[goku_labels.Host] = req.Host
labels[goku_labels.Path] = req.URL.Path labels[goku_labels.Path] = req.URL.Path
labels[goku_labels.Method] = req.Method labels[goku_labels.Method] = req.Method
monitor.ProxyMonitor.Observe(float64( delay.Milliseconds()),labels) monitor.ProxyMonitor.Observe(float64(delay/time.Millisecond), labels)
}() }()
req.Header.Set("Accept-Encoding", "gzip") req.Header.Set("Accept-Encoding", "gzip")
req.Header = parseHeaders(r.headers) req.Header = parseHeaders(r.headers)
......
...@@ -2,13 +2,14 @@ package gateway ...@@ -2,13 +2,14 @@ package gateway
import ( import (
"fmt" "fmt"
"github.com/eolinker/goku-api-gateway/diting"
goku_labels "github.com/eolinker/goku-api-gateway/goku-labels"
"github.com/eolinker/goku-api-gateway/node/monitor"
"net/http" "net/http"
"strconv" "strconv"
"time" "time"
"github.com/eolinker/goku-api-gateway/diting"
goku_labels "github.com/eolinker/goku-api-gateway/goku-labels"
"github.com/eolinker/goku-api-gateway/node/monitor"
log "github.com/eolinker/goku-api-gateway/goku-log" log "github.com/eolinker/goku-api-gateway/goku-log"
access_log "github.com/eolinker/goku-api-gateway/goku-node/access-log" access_log "github.com/eolinker/goku-api-gateway/goku-node/access-log"
"github.com/eolinker/goku-api-gateway/goku-node/common" "github.com/eolinker/goku-api-gateway/goku-node/common"
...@@ -53,7 +54,7 @@ func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { ...@@ -53,7 +54,7 @@ func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
n, status := ctx.Finish() n, status := ctx.Finish()
delay:= time.Since(timeStart) delay := time.Since(timeStart)
ctx.LogFields[fields.RequestID] = requestID ctx.LogFields[fields.RequestID] = requestID
ctx.LogFields[fields.StatusCode] = status ctx.LogFields[fields.StatusCode] = status
...@@ -66,15 +67,12 @@ func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { ...@@ -66,15 +67,12 @@ func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
access_log.Log(ctx.LogFields) access_log.Log(ctx.LogFields)
log.WithFields(ctx.LogFields).Info() log.WithFields(ctx.LogFields).Info()
// 监控计数 // 监控计数
labels:= make(diting.Labels) labels := make(diting.Labels)
labels[goku_labels.API] = strconv.Itoa(ctx.ApiID()) labels[goku_labels.API] = strconv.Itoa(ctx.ApiID())
labels[goku_labels.Strategy] = ctx.StrategyId() labels[goku_labels.Strategy] = ctx.StrategyId()
labels[goku_labels.Status] = strconv.Itoa(status) labels[goku_labels.Status] = strconv.Itoa(status)
monitor.APIMonitor.Observe( float64( delay.Milliseconds()),labels) monitor.APIMonitor.Observe(float64(delay/time.Millisecond), labels)
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册