model

package
v0.0.0-...-22b3256 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DevelopmentMode 开发模式
	DevelopmentMode = "development"

	// TestMode 测试模式
	TestMode = "test"

	// ProductionMode 产品模式
	ProductionMode = "production"
)

Variables

View Source
var DB *gorm.DB

DB mysql数据库连接

View Source
var ErrorCode = errorCode{
	SUCCESS:      0,
	ERROR:        1,
	NotFound:     404,
	LoginError:   1000,
	LoginTimeOut: 1001,
	InActive:     1002,
}

ErrorCode 错误赋值

View Source
var RedisPool *redis.Pool

RedisPool Redis连接池

Functions

func UserToRedis

func UserToRedis(tokenString string, user User) error

UserToRedis 将用户信息存到redis

Types

type API

type API struct {
	Appid      string `json:"appid" binding:"required"`
	Name       string `json:"name" binding:"required"`
	Data       string `json:"datevalue" binding:"required"`
	PageSize   int    `json:"pagesize" binding:"required,numeric"`
	PageNumber int    `json:"pagenumber" binding:"required,numeric"`
}

API API

type AggMetrics

type AggMetrics struct {
	Took     int    `json:"took"`
	ScrollID string `json:"_scroll_id"`
	Hits     struct {
		Total    int           `json:"total"`
		MaxScore int           `json:"max_score"`
		Hits     []interface{} `json:"hits"`
	} `json:"hits"`
	Suggest      interface{} `json:"suggest"`
	Aggregations struct {
		DataAggs struct {
			Buckets []Bucket `json:"buckets"`
		} `json:"DataAggs"`
	} `json:"aggregations"`
	TimedOut bool `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
}

AggMetrics 日志聚合对象

type AggResult

type AggResult struct {
	Min             [24]float64 `json:"min" binding:"required"`
	Max             [24]float64 `json:"max" binding:"required"`
	Avg             [24]float64 `json:"avg" binding:"required"`
	Count           [24]int     `json:"count" binding:"required"`
	TotalCount      int         `json:"totalCount" binding:"required"`
	ShareTotalCount int         `json:"shareTotalCount" binding:"required"`
}

AggResult 聚合的结果

type Bucket

type Bucket struct {
	KeyAsString time.Time `json:"key_as_string"`
	Key         int64     `json:"key"`
	DocCount    int       `json:"doc_count"`
	MaxAgg      struct {
		Value float64 `json:"value"`
	} `json:"maxAgg"`
	MinAgg struct {
		Value float64 `json:"value"`
	} `json:"minAgg"`
	AvgAgg struct {
		Value float64 `json:"value"`
	} `json:"avgAgg"`
}

Bucket Bucket 对象

type DateValue

type DateValue struct {
	LogstashName string `json:"logstastname" binding:"required`
}

DateValue DateValue

type ID

type ID struct {
	ID        string `json:"id" binding:"required"`
	IndexName string `json:"indexname" binding:"required"`
}

ID ID

type LoadAggChart

type LoadAggChart struct {
	LogstashName string `json:"logstastname" binding:"required`
	Name         string `json:"name" binding:"required`
}

LoadAggChart post请求过来的数据

type Logs

type Logs struct {
	Took     int    `json:"took"`
	ScrollID string `json:"_scroll_id"`
	Hits     struct {
		Total    int `json:"total"`
		MaxScore int `json:"max_score"`
		Hits     []struct {
			Score     int         `json:"_score"`
			Index     string      `json:"_index"`
			Type      string      `json:"_type"`
			ID        string      `json:"_id"`
			UID       string      `json:"_uid"`
			Routing   string      `json:"_routing"`
			Parent    string      `json:"_parent"`
			Version   interface{} `json:"_version"`
			Sort      interface{} `json:"sort"`
			Highlight interface{} `json:"highlight"`
			Source    struct {
				Request struct {
					Headers struct {
						Host      string `json:"host"`
						Accept    string `json:"accept"`
						UserAgent string `json:"user-agent"`
					} `json:"headers"`
					Size        string `json:"size"`
					Method      string `json:"method"`
					Querystring struct {
					} `json:"querystring"`
					URI string `json:"uri"`
					URL string `json:"url"`
				} `json:"request"`
				// Tries []struct {
				// 	Port            int    `json:"port"`
				// 	BalancerLatency int    `json:"balancer_latency"`
				// 	IP              string `json:"ip"`
				// } `json:"tries"`
				Latencies struct {
					Request int `json:"request"`
					Proxy   int `json:"proxy"`
					Kong    int `json:"kong"`
				} `json:"latencies"`
				UpstreamURI string `json:"upstream_uri"`
				// Message     string    `json:"message"`
				Timestamp time.Time `json:"@timestamp"`
				Port      int       `json:"port"`
				Response  struct {
					Headers struct {
						Date                 string `json:"date"`
						Server               string `json:"server"`
						XKongUpstreamLatency string `json:"x-kong-upstream-latency"`
						XKongProxyLatency    string `json:"x-kong-proxy-latency"`
						ContentType          string `json:"content-type"`
						Connection           string `json:"connection"`
						Via                  string `json:"via"`
					} `json:"headers"`
					Size   string `json:"size"`
					Status int    `json:"status"`
				} `json:"response"`
				Version   string    `json:"@version"`
				Host      string    `json:"host"`
				StartedAt time.Time `json:"started_at"`
				ClientIP  string    `json:"client_ip"`
				API       struct {
					UpstreamSendTimeout    int      `json:"upstream_send_timeout"`
					UpstreamURL            string   `json:"upstream_url"`
					HTTPSOnly              bool     `json:"https_only"`
					Methods                []string `json:"methods"`
					CreatedAt              int64    `json:"created_at"`
					PreserveHost           bool     `json:"preserve_host"`
					HTTPIfTerminated       bool     `json:"http_if_terminated"`
					Retries                int      `json:"retries"`
					Uris                   []string `json:"uris"`
					UpstreamConnectTimeout int      `json:"upstream_connect_timeout"`
					StripURI               bool     `json:"strip_uri"`
					Name                   string   `json:"name"`
					ID                     string   `json:"id"`
					UpstreamReadTimeout    int      `json:"upstream_read_timeout"`
				} `json:"api"`
				Consumer struct {
					CustomID  string `json:"custom_id"`
					CreatedAt int64  `json:"created_at"`
					ID        string `json:"id"`
					Username  string `json:"username"`
				} `json:"consumer"`
			} `json:"_source"`
			Fields         interface{} `json:"fields"`
			Explanation    interface{} `json:"_explanation"`
			MatchedQueries interface{} `json:"matched_queries"`
			InnerHits      interface{} `json:"inner_hits"`
		} `json:"hits"`
	} `json:"hits"`
	Suggest      interface{} `json:"suggest"`
	Aggregations interface{} `json:"aggregations"`
	TimedOut     bool        `json:"timed_out"`
	Shards       struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
}

Logs 日志实体

type Page

type Page struct {
	Appid      string `json:"appid" binding:"required"`
	PageSize   int    `json:"pagesize" binding:"required,numeric"`
	PageNumber int    `json:"pagenumber" binding:"required,numeric"`
	DateValue  string `json:"datevalue" binding:"required"`
}

Page 分页

type PieMetrics

type PieMetrics struct {
	Took     int    `json:"took"`
	ScrollID string `json:"_scroll_id"`
	Hits     struct {
		Total    int           `json:"total"`
		MaxScore int           `json:"max_score"`
		Hits     []interface{} `json:"hits"`
	} `json:"hits"`
	Suggest      interface{} `json:"suggest"`
	Aggregations struct {
		RangeAgg struct {
			Buckets []struct {
				Key      string  `json:"key"`
				To       float64 `json:"to"`
				DocCount int     `json:"doc_count"`
				From     float64 `json:"from,omitempty"`
			} `json:"buckets"`
		} `json:"rangeAgg"`
	} `json:"aggregations"`
	TimedOut bool `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
}

PieMetrics Pie聚合返回的实体

type PieResult

type PieResult struct {
	Value int    `json:"value"`
	Name  string `json:"name"`
}

PieResult 返回Pie结果

type ResultBuckets

type ResultBuckets struct {
	Key string `json:"key"`
}

ResultBuckets bucketResult

type URL

type URL struct {
	Took     int    `json:"took"`
	ScrollID string `json:"_scroll_id"`
	Hits     struct {
		Total    int           `json:"total"`
		MaxScore int           `json:"max_score"`
		Hits     []interface{} `json:"hits"`
	} `json:"hits"`
	Suggest      interface{} `json:"suggest"`
	Aggregations struct {
		TermAgg struct {
			DocCountErrorUpperBound int             `json:"doc_count_error_upper_bound"`
			SumOtherDocCount        int             `json:"sum_other_doc_count"`
			Buckets                 []ResultBuckets `json:"buckets"`
		} `json:"termAgg"`
	} `json:"aggregations"`
	TimedOut bool `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
}

URL 查询urlname

type User

type User struct {
	ID       int    `gorm:"primary_key" json:"id"`
	Name     string `json:"name"`
	Password string `json:"password"`
	IsActive bool   `json:"isactive"`
	AppID    string `json:"appid"`
}

User 用户表

func UserFromRedis

func UserFromRedis(tokenString string) (User, error)

UserFromRedis 从redis中取出用户信息

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL