node

package
v0.0.0-...-2d3ae32 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2018 License: GPL-3.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	USERS_INDEX        = ".lessmore_points"
	USERS_DOC_TYPE     = "points"
	NODE_ADDRESS       = "dynamic"
	AUTH_STRING_LENGTH = 16
	LETTERS            = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
	SALT_BYTES         = 32
	HASH_BYTES         = 64
)

Variables

This section is empty.

Functions

func DeleteUser

func DeleteUser(name string) error

DeleteUser from users index

func LogRequest

func LogRequest(r *http.Request)

LogRequest ...

func MakePlainTextMessage

func MakePlainTextMessage(hit i2es.ESDoc) []byte

MakePlainTextMessage ...

func Serve

func Serve(listen string, es ESConf)

Serve ...

func XFeaturesHandler

func XFeaturesHandler(w http.ResponseWriter, r *http.Request)

XFeaturesHandler list supported features

Types

type Bucket

type Bucket struct {
	Key      string `json:"key"`
	DocCount int    `json:"doc_count"`
}

Bucket ...

type ESConf

type ESConf i2es.ESConf

ESConf ...

func (ESConf) AddNewUser

func (es ESConf) AddNewUser(name, email string) (User, error)

AddNewUser to the .lessmore_users index

func (ESConf) BlacklistTXT

func (ed ESConf) BlacklistTXT(w http.ResponseWriter, r *http.Request)

func (ESConf) EHandler

func (es ESConf) EHandler(w http.ResponseWriter, r *http.Request)

EHandler /e/ schema

func (ESConf) GetEchoMessageHashes

func (es ESConf) GetEchoMessageHashes(echo string) []string

GetEchoMessageHashes ...

func (ESConf) GetLimitedEchoMessageHashes

func (es ESConf) GetLimitedEchoMessageHashes(echo string, offset int, limit int) []string

GetLimitedEchoMessageHashes ...

func (ESConf) GetListTXT

func (es ESConf) GetListTXT() []byte

GetListTXT ...

func (ESConf) GetPlainTextMessage

func (es ESConf) GetPlainTextMessage(msgid string) []byte

GetPlainTextMessage ...

func (ESConf) GetUEchoMessageHashes

func (es ESConf) GetUEchoMessageHashes(echoes string) []string

GetUEchoMessageHashes ...

func (ESConf) GetUMMessages

func (es ESConf) GetUMMessages(msgs string) []string

func (ESConf) GetXC

func (es ESConf) GetXC(echoes string) []string

GetXC implements /x/c

func (ESConf) IndexMessage

func (es ESConf) IndexMessage(msg idec.Message) error

func (ESConf) IndexUser

func (es ESConf) IndexUser(user User) error

IndexUser in `USERS_INDEX` index

func (ESConf) ListTXTHandler

func (es ESConf) ListTXTHandler(w http.ResponseWriter, r *http.Request)

ListTXTHandler ...

func (ESConf) MHandler

func (es ESConf) MHandler(w http.ResponseWriter, r *http.Request)

MHandler /m/ schema

func (ESConf) PointMessage

func (es ESConf) PointMessage(req PointRequest, user User) error

PointMessage add point message into DB

func (ESConf) UEHandler

func (es ESConf) UEHandler(w http.ResponseWriter, r *http.Request)

UEHandler /u/e/ schema

func (ESConf) UMHandler

func (es ESConf) UMHandler(w http.ResponseWriter, r *http.Request)

UMHandler /u/m/ schema

func (ESConf) UPointHandler

func (es ESConf) UPointHandler(w http.ResponseWriter, r *http.Request)

UPointHandler /u/point scheme

func (ESConf) XCHandler

func (es ESConf) XCHandler(w http.ResponseWriter, r *http.Request)

XCHandler /x/c schema

type ESDoc

type ESDoc struct {
	Echo    string `json:"echo"`
	Subg    string `json:"subg"`
	To      string `json:"to"`
	Author  string `json:"author"`
	Message string `json:"message"`
	Date    string `json:"date"`
	MsgID   string `json:"msgid"`
	Tags    string `json:"tags"`
	Repto   string `json:"repto"`
	Address string `json:"address"`
	TopicID string `json:"topicid"`
}

type ESSearchResp

type ESSearchResp struct {
	Took           int64 `json:"took"`
	TimedOut       bool  `json:"timed_out"`
	ESSearchShards `json:"_shards"`
	Hits           `json:"hits"`
}

{"took":467,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":89333,"max_score":0.0,"hits":[]}}

type ESSearchShards

type ESSearchShards struct {
	Total      int64 `json:"total"`
	Successful int64 `json:"successful"`
	Skipped    int64 `json:"skipped"`
	Failed     int64 `json:"failed"`
}

type EchoAgg

type EchoAgg struct {
	DocCountErrorUpperBound int64    `json:"doc_count_error_upper_bound"`
	SumOtherDocCount        int64    `json:"sum_other_doc_count"`
	Buckets                 []Bucket `json:"buckets"`
}

type EchoAggregations

type EchoAggregations struct {
	EchoAgg  map[string]EchoAgg `json:"aggregations"`
	UniqEcho map[string]Uniq    `json:"uniqueEcho"`
}

"aggregations":{"echo":{"doc_count_error_upper_bound":2406,"sum_other_doc_count":76555,"buckets":[{"key":"bash.rss","doc_count":12779}]},"uniqueEcho":{"value":121}}}

type EchoBucket

type EchoBucket struct {
	Key   string `json:"key"`
	Count int64  `json:"doc_count"`
}

type Hit

type Hit struct {
	Index  string     `json:"_index"`
	Type   string     `json:"_type"`
	ID     string     `json:"_id"`
	Source i2es.ESDoc `json:"_source"`
}

{"_index":"idec5","_type":"post","_id":"aAjSbXS5XeNF6lVaPh5A","_score":1.0,"_source"

type Hits

type Hits struct {
	Total    int64   `json:"total"`
	MaxScore float64 `json:"max_score"`
	Hits     []Hit   `json:"hits"`
}

type MaxIdAggregation

type MaxIdAggregation struct {
	Hits  UserHits        `json:"hits"`
	MaxID map[string]Uniq `json:"aggregations"`
}

type PointRequest

type PointRequest struct {
	Pauth string `json:"pauth"`
	Tmsg  string `json:"tmsg"`
}

PointRequest with message

type Uniq

type Uniq struct {
	Value float64 `json:"value"`
}

type User

type User struct {
	// Will be added to the address:
	// i.e. dynamic,1
	UserID int64 `json:"user_id"`
	// Will be added to the bundled message
	Name string `json:"name"`
	// Email address needs for password restore
	Email      string `json:"email"`
	AuthString string `json:"auth_string"`
	Address    string `json:"address"`
	// Created time
	Created int64 `json:"created"`
}

User document structure

type UserHit

type UserHit struct {
	Index  string  `json:"_index"`
	Type   string  `json:"_type"`
	ID     string  `json:"_id"`
	Score  float64 `json:"_score"`
	Source User    `json:"_source"`
}

{ "_index":".lessmore_users","_type":"user","_id":"1","_score":1.0,

"_source":{"id": 1, "address": "dynamic", "name": "name", "authString": "thisIsAtest"}}

type UserHits

type UserHits struct {
	Total    int64     `json:"total"`
	MaxScore float64   `json:"max_score"`
	Hits     []UserHit `json:"hits"`
}

Jump to

Keyboard shortcuts

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