stat

package module
v0.0.0-...-21f0bce Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2016 License: MIT Imports: 22 Imported by: 0

README

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UidCookieName  = "u"
	SsidCookieName = "s"
)
View Source
var (
	ErrUnknownSite = fmt.Errorf("unknown site")

	UidCookieMaxAge = 60 * 60 * 24 * 366 * 5
)
View Source
var (
	SITE_BUCKET       = "sites"
	URI_BUCKET        = "uri"
	USER_AGENT_BUCKET = "ua"
	USER_ID_BUCKET    = "uuids"
	SESSION_ID_BUCKET = "session"

	HITS_LEDIS_KEY = "hits"

	BINLOGS_DIR = "binlogs"

	HyperlogPrecision uint8 = 7
)
View Source
var (
	DefaultBlockLen = 36
)

Functions

This section is empty.

Types

type Binlog

type Binlog struct {
	// contains filtered or unexported fields
}

func NewWriteBinLog

func NewWriteBinLog(fpath string) (*Binlog, error)

func (*Binlog) Append

func (bl *Binlog) Append(bts []byte) error

func (*Binlog) Archive

func (bl *Binlog) Archive(path string) error

func (*Binlog) Release

func (bl *Binlog) Release() error

func (*Binlog) SetBlockLen

func (bl *Binlog) SetBlockLen(l int)

type Hit

type Hit struct {
	Created   time.Time
	Host      string
	Uri       string
	Referer   string
	Ip        string
	UserAgent string
	Ssid      string
	Uid       string
	// contains filtered or unexported fields
}

func NewHit

func NewHit(host, uri, referer, ip, userAgent, ssid, uid string) *Hit

func NewHitFromRequest

func NewHitFromRequest(req *http.Request) (*Hit, error)

func (*Hit) AsBytes

func (h *Hit) AsBytes() ([]byte, error)

func (*Hit) SetStore

func (h *Hit) SetStore(store *Store)

func (*Hit) SiteId

func (h *Hit) SiteId() (int64, error)

type Service

type Service struct {
	*Store
}

func New

func New(dataPath string) (*Service, error)

func (*Service) AddSite

func (s *Service) AddSite(host string) error

func (*Service) HandleHit

func (s *Service) HandleHit(w http.ResponseWriter, req *http.Request) error

func (*Service) Hit

func (s *Service) Hit(host string, uri string, referer, ip string, userAgent string, ssid string, uid string) error

func (*Service) Save

func (s *Service) Save(h *Hit)

func (*Service) Stat

func (s *Service) Stat(host string) (*Stat, error)

type Site

type Site struct {
	Id   int64
	Host string
}

type Stat

type Stat struct {
	SiteId    int64
	Rank      int64
	TodayHit  int64
	TodayUniq int64
}

func NewStat

func NewStat() *Stat

type Store

type Store struct {
	DbPath string
	// contains filtered or unexported fields
}

func NewStore

func NewStore(DbPath string) (*Store, error)

func (*Store) ArchiveBinlog

func (s *Store) ArchiveBinlog() error

func (*Store) ArchiveBinlogIfNeeded

func (s *Store) ArchiveBinlogIfNeeded() error

func (*Store) ArchiveBinlogIfNeededEvery

func (s *Store) ArchiveBinlogIfNeededEvery(d time.Duration)

func (*Store) Binlog

func (s *Store) Binlog() *Binlog

func (*Store) CreateBucket

func (s *Store) CreateBucket(bucket string) error

func (*Store) Flush

func (s *Store) Flush(siteId int64) error

func (*Store) Get

func (s *Store) Get(bucket string, key string) (id int64, e error)

func (*Store) GetBytes

func (s *Store) GetBytes(bucket string, key []byte) (id int64, e error)

func (*Store) GetOrInsert

func (s *Store) GetOrInsert(bucket string, key string) (id int64, e error)

func (*Store) GetOrInsertBytes

func (s *Store) GetOrInsertBytes(bucket string, key []byte) (id int64, e error)

func (*Store) Has

func (s *Store) Has(bucket string, key string) (has bool, e error)

func (*Store) HasBucket

func (s *Store) HasBucket(bucket string) (has bool, e error)

func (*Store) HasBytes

func (s *Store) HasBytes(bucket string, key []byte) (has bool, e error)

func (*Store) HasSite

func (s *Store) HasSite(host string) (bool, error)

func (*Store) HitCount

func (s *Store) HitCount(siteId int64) (cnt int64, e error)

func (*Store) IncHit

func (s *Store) IncHit(siteId int64) (int64, error)

func (*Store) InsertAutoInc

func (s *Store) InsertAutoInc(bucket string, key string) (int64, error)

func (*Store) InsertAutoIncBytes

func (s *Store) InsertAutoIncBytes(bucket string, key []byte) (int64, error)

func (*Store) LastFlush

func (s *Store) LastFlush(siteId int64) (time.Time, error)

func (*Store) NeedFlush

func (s *Store) NeedFlush(siteId int64) (bool, error)

func (*Store) Rank

func (s *Store) Rank(siteId int64) (rank int64, e error)

func (*Store) RefererId

func (s *Store) RefererId(ref string) (siteId int64, uriId int64, e error)

func (*Store) SessionId

func (s *Store) SessionId(ssid string) (int64, error)

func (*Store) SetFlush

func (s *Store) SetFlush(siteId int64) error

func (*Store) SiteId

func (s *Store) SiteId(host string) (id int64, e error)

func (*Store) TodayUnique

func (s *Store) TodayUnique(siteId int64, uid int64) (cnt int64, e error)

func (*Store) TodayUniqueCount

func (s *Store) TodayUniqueCount(siteId int64) (cnt int64, e error)

func (*Store) UriId

func (s *Store) UriId(uri string) (int64, error)

func (*Store) UserAgentId

func (s *Store) UserAgentId(uri string) (int64, error)

func (*Store) UserId

func (s *Store) UserId(uid string) (int64, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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