Documentation
¶
Index ¶
- Variables
- func DecodeJSONToMap(x *json.RawMessage) (interface{}, error)
- func Pwd() string
- type Addresses
- type BaseStatsItem
- type CallBackFunc
- type ClientRequest
- type CountByTime
- type DBRead
- func (b *DBRead) Count(db, table string, q *querypara.Query) (int64, error)
- func (b *DBRead) Gets(db, table string, ids []string, decode decodeDBRecord) ([]interface{}, error)
- func (b *DBRead) LastConvertSeq() int64
- func (b *DBRead) List(db, table string, q *querypara.Query, ...) ([]interface{}, error)
- func (b *DBRead) NewESShortConnect() (escli.ESClient, error)
- func (b *DBRead) Search(db, table string, req *querypara.Query, decode decodeDBRecord) ([]interface{}, error)
- func (b *DBRead) Searches(db, table string, reqs []*querypara.Query, decode decodeDBRecord) ([][]interface{}, error)
- type DonateStatsItem
- type DonationStats
- type Hashes
- type Organizations
- type QMatch
- type QMatchKey
- type QPage
- type QRange
- type QRanges
- type QSort
- type Range
- type RepDonationStat
- type RepDonationStates
- type RepLastSeq
- type RepSubTermsAgg
- type RepTermsAgg
- type RepVolunteerStat
- type ServerResponse
- type SpecifiedFields
- type StatsComm
- type StatsCommInfo
- func (bi *StatsCommInfo) GetInterval() int64
- func (bi *StatsCommInfo) GetIsRefreshing() bool
- func (bi *StatsCommInfo) GetLastCallTime() int64
- func (bi *StatsCommInfo) GetLastSeq() int64
- func (bi *StatsCommInfo) GetRep() interface{}
- func (bi *StatsCommInfo) GetReq() interface{}
- func (bi *StatsCommInfo) GetTimeout() *time.Timer
- func (bi *StatsCommInfo) PrintStatusJSON() string
- func (bi *StatsCommInfo) SetIsRefreshing(IsRefreshing bool)
- func (bi *StatsCommInfo) SetLastSeq(lastseq int64)
- func (bi *StatsCommInfo) SetTimeout(timeout *time.Timer)
- func (bi *StatsCommInfo) StatsHandle(req interface{}) (interface{}, error)
- func (bi *StatsCommInfo) StopTimeOut()
- func (bi *StatsCommInfo) Update(rep interface{})
- type StatsItem
- type StatsItemStatus
- type TotalStats
- type VolunteerStats
- type VolunteerStatsItem
Constants ¶
This section is empty.
Variables ¶
var ( ErrBadParam = errors.New("Bad Param") ErrNotFound = errors.New("Not Found") ErrTypeAsset = errors.New("Type Asset failed") ErrSearchSize = errors.New("Search Return Size not match") )
var ( DonateFlag = 1 VolunteerFlag = 2 MaxStatsItems = 5 )
Functions ¶
func DecodeJSONToMap ¶
func DecodeJSONToMap(x *json.RawMessage) (interface{}, error)
DecodeJSONToMap Decode json data to map[string]interface{}
Types ¶
type Addresses ¶
type Addresses struct {
Address []string `json:"address"` // 地址列表
}
Addresses Addresses
type BaseStatsItem ¶
type BaseStatsItem struct { ChildStatsItems []StatsItem // 子统计项组件列表 MaxStatsItems int sync.RWMutex }
BaseStatisItem 基础统计项组件
func (*BaseStatsItem) AddStatsItem ¶
func (b *BaseStatsItem) AddStatsItem(s StatsItem)
AddStatisItem 添加新的统计项
func (*BaseStatsItem) GetStatsItem ¶
func (b *BaseStatsItem) GetStatsItem() []StatsItem
GetStatisItem 获取已经缓存的统计项信息
type CallBackFunc ¶
type CallBackFunc func(req interface{}) (interface{}, error)
type ClientRequest ¶
type ClientRequest struct { Method string `json:"method"` // 请求方法 Params [1]*json.RawMessage `json:"params"` // 请求参数 ID uint64 `json:"id"` // 请求标识 }
type CountByTime ¶
type DBRead ¶
type DBRead struct { Title string Prefix string Host string Symbol string Version int32 ID string Username string Password string }
DBRead DBRead
func (*DBRead) LastConvertSeq ¶
LastConvertSeq 获取已经解析的最新seq值
func (*DBRead) List ¶
func (b *DBRead) List(db, table string, q *querypara.Query, decoder func(x *json.RawMessage) (interface{}, error)) ([]interface{}, error)
List 列表
func (*DBRead) NewESShortConnect ¶
NewESShortConnect new a es short connect
type DonateStatsItem ¶
StatsItemInfo具体统计项的信息
func (*DonateStatsItem) IsMatch ¶
func (bi *DonateStatsItem) IsMatch(falgType int, reqinfo interface{}) bool
IsMatch 比较需要统计的信息和现有cache统计信息是否匹配
func (*DonateStatsItem) PrintStatsItemJSON ¶
func (bi *DonateStatsItem) PrintStatsItemJSON() string
PrintJson 通过json格式打印字符串
type DonationStats ¶
type DonationStats struct { Match []*QMatch `json:"match"` // 匹配条件 TermsAgg *QMatchKey `json:"termsAgg"` // 聚合字段 SubSumAgg *QMatchKey `json:"subSumAgg"` // 子聚合字段 }
DonationStats DonationStats 用于统计指定字段的捐款并排名
type Hashes ¶
type Hashes struct {
Hash []string `json:"hash"` // 哈希列表
}
Hashes 交易hash数组 swagger:parameters Hashes
type Organizations ¶
type Organizations struct {
Organization []string `json:"organization"` // 组织列表
}
Organizations Organization
type QMatch ¶
type QMatch struct { Key string `json:"key"` // 字段名 Value interface{} `json:"value"` // 值 }
swagger:parameters QMatch
type QRange ¶
type QRange struct { Key string `json:"key"` // 字段名 RStart interface{} `json:"start"` // 开始位置(大于等于) REnd interface{} `json:"end"` // 结束位置(小于等于) GT interface{} `json:"gt"` // 大于 LT interface{} `json:"lt"` // 小于 }
swagger:parameters QRange
type Range ¶
type Range struct { RStart interface{} `json:"start"` // 开始位置(大于等于) REnd interface{} `json:"end"` // 结束位置(小于等于) }
type RepDonationStat ¶
type RepDonationStat struct { Name string `json:"name"` // 名字 Total float64 `json:"total"` // 总和 Count int64 `json:"count"` // 个数 }
RepDonationStat 捐款排名统计结果:返回捐款人名以及捐款额度
type RepDonationStates ¶
type RepDonationStates struct {
Itemes []*RepDonationStat `json:"itemes"` // 项
}
type RepLastSeq ¶
type RepLastSeq struct { LastSyncSeq int64 `json:"lastSyncSeq"` // 最新同步区块高度 LastConvertSeq int64 `json:"lastConvertSeq"` // 最新解析区块高度 }
RepLastSeq 最新的seq序列号
type RepSubTermsAgg ¶
type RepSubTermsAgg struct { SubTermsAggKey string `json:"subTermsAggKey"` // 子聚合字段 Count int64 `json:"count"` // 计数 }
RepSubTermsAgg 单位
type RepTermsAgg ¶
type RepTermsAgg struct { Count int64 `json:"count"` // 计数 TermsAggKey string `json:"termsAggKey"` // 聚合字段 SubTermsAgges []*RepSubTermsAgg `json:"subTermsAgges"` // 子聚合字段 }
RepTermsAgg 省份信息:
type RepVolunteerStat ¶
type RepVolunteerStat struct { TermsAgges []*RepTermsAgg `json:"termsAgges"` // 聚合信息 Count int64 `json:"count"` // 计数 }
RepVolunteerStat 志愿者分布图统计
type ServerResponse ¶
type ServerResponse struct { ID uint64 `json:"id"` // 请求标识 Result interface{} `json:"result"` // 返回结果 Error interface{} `json:"error"` // 错误描述 }
type SpecifiedFields ¶
type SpecifiedFields struct { Match []*QMatch `json:"match"` // 匹配条件 Sort []*QSort `json:"sort"` // 排序 Count int `json:"count"` // 总量 Fields []string `json:"fields"` // 字段列表 }
SpecifiedFields 用于获取指定字段的值,例如获取某个省份某个单位志愿者的姓名
type StatsComm ¶
type StatsComm interface { SetLastSeq(lastseq int64) GetLastSeq() int64 SetTimeout(timeout *time.Timer) GetTimeout() *time.Timer StopTimeOut() SetIsRefreshing(IsRefreshing bool) GetIsRefreshing() bool GetInterval() int64 GetLastCallTime() int64 Update(rep interface{}) GetRep() interface{} GetReq() interface{} PrintStatusJSON() string StatsHandle(req interface{}) (interface{}, error) }
func NewStatsComm ¶
func NewStatsComm(req, rep interface{}, interval int64, lastSeq int64, callBack CallBackFunc) StatsComm
NewStatsComm 创建一个新的统计公共实例
type StatsCommInfo ¶
type StatsCommInfo struct { Req interface{} Rep interface{} Interval int64 LastSeq int64 LastCallTime int64 IsRefreshing bool sync.RWMutex CallBack CallBackFunc // contains filtered or unexported fields }
定义一个缓存慈善全款统计信息的结构,底层定时刷新到cache中,前端直接访问cache中的即可 Req 用于统计的条件 Rep 统计的结果 Interval 定时统计的时间间隔 LastSeq 定时刷新时的最新区块的seq,如果seq没有增加就不去刷新直接使用cache缓存的统计信息 LastCallTime 此缓存数据被调用的最新时间,用于缓存项超过最大值时删除最旧没有被调用的统计项,防止缓存数据太多 IsRefreshing 标记此项统计是否正在进行,如果正在统计进行时不再触发统计,等待下个周期再刷新统计
func (*StatsCommInfo) GetInterval ¶
func (bi *StatsCommInfo) GetInterval() int64
func (*StatsCommInfo) GetIsRefreshing ¶
func (bi *StatsCommInfo) GetIsRefreshing() bool
func (*StatsCommInfo) GetLastCallTime ¶
func (bi *StatsCommInfo) GetLastCallTime() int64
func (*StatsCommInfo) GetLastSeq ¶
func (bi *StatsCommInfo) GetLastSeq() int64
func (*StatsCommInfo) GetTimeout ¶
func (bi *StatsCommInfo) GetTimeout() *time.Timer
func (*StatsCommInfo) PrintStatusJSON ¶
func (bi *StatsCommInfo) PrintStatusJSON() string
func (*StatsCommInfo) SetIsRefreshing ¶
func (bi *StatsCommInfo) SetIsRefreshing(IsRefreshing bool)
func (*StatsCommInfo) SetLastSeq ¶
func (bi *StatsCommInfo) SetLastSeq(lastseq int64)
func (*StatsCommInfo) SetTimeout ¶
func (bi *StatsCommInfo) SetTimeout(timeout *time.Timer)
func (*StatsCommInfo) StatsHandle ¶
func (bi *StatsCommInfo) StatsHandle(req interface{}) (interface{}, error)
StatsHandle 比较需要统计的信息和现有cache统计信息是否匹配
func (*StatsCommInfo) StopTimeOut ¶
func (bi *StatsCommInfo) StopTimeOut()
type StatsItem ¶
type StatsItem interface { IsMatch(falgType int, req interface{}) bool PrintStatsItemJSON() string StatsComm }
统计项组件的方法集 StatsItem
type StatsItemStatus ¶
type TotalStats ¶
type TotalStats struct { Match []*QMatch `json:"match"` // 匹配条件 SumAgg *QMatchKey `json:"sumAgg"` // 聚合字段 }
TotalStats 用于统计指定字段值的总和
type VolunteerStats ¶
type VolunteerStats struct { Match []*QMatch `json:"match"` // 匹配条件 TermsAgg *QMatchKey `json:"termsAgg"` // 聚合字段 SubTermsAgg *QMatchKey `json:"subTermsAgg"` // 子组合字段 SubSumAgg *QMatchKey `json:"subSumAgg"` // 子统计字段 }
VolunteerStats 用于统计志愿者分布图:按照省分桶,再按照单位分桶
type VolunteerStatsItem ¶
VolunteerStatsItem 具体统计项的信息
func (*VolunteerStatsItem) FlagType ¶
func (bi *VolunteerStatsItem) FlagType() int
FalgType 返回统计项的类型
func (*VolunteerStatsItem) IsMatch ¶
func (bi *VolunteerStatsItem) IsMatch(falgType int, reqinfo interface{}) bool
IsMatch 比较需要统计的信息和现有cache统计信息是否匹配
func (*VolunteerStatsItem) PrintStatsItemJSON ¶
func (bi *VolunteerStatsItem) PrintStatsItemJSON() string
PrintJson 通过json格式打印字符串