huck

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: Unlicense Imports: 13 Imported by: 0

README

Huck

Go codecov Go Report Card

Huck is a simple data collection server program, It's built on top of the Echo. that achieves the purpose of statistics through API calls. Huck is characterized by simple configuration and can be deployed without external network dependencies.

Using

# Statisticians used.
counter:

  #  Here is the route used
  - name: "测试员"
    path: "/week"

Handlers

The following statistics are currently available:

  • counter

Documentation

Index

Constants

View Source
const (
	// DefaultConfigFileName [Constant]
	DefaultConfigFileName = "huck.yml"

	// DefaultCounterFileName [Constant]
	DefaultCounterFileName = "huck.counter.txt"
)
View Source
const (
	// StatisticsFileFormatError [Constant]
	StatisticsFileFormatError = "Huck has detected an existing statistics file, but the format is not correct. Please fix it manually."
)

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString to []byte to string.

func IsFileExist

func IsFileExist(filename string) bool

IsFileExist to quick check file is exist.

func Run

func Run(conFilename string)

Run huck application.

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes to string to []byte.

Types

type Configuration

type Configuration struct {
	Counter []struct {
		Name string
		Path string
	}
}

Configuration is the object structure of huck.yml.

func FromConfigFile

func FromConfigFile(filename string) *Configuration

FromConfigFile from huck.yml read data to Configuration struct.

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration to create a empty Configuration struct.

type Counter

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

Counter statisticians.

func NewCounterHandler

func NewCounterHandler(name string, path string) *Counter

NewCounterHandler to initializer a Counter.

func (*Counter) GetCount

func (counter *Counter) GetCount() uint64

GetCount is get count of counter.

func (*Counter) Handler

func (counter *Counter) Handler(ctx echo.Context) error

Handler is Counter logic.

func (*Counter) Path

func (counter *Counter) Path() string

Path is route url.

type CounterStorage

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

CounterStorage is Counter persistence device.

func InitCounterStorage

func InitCounterStorage() *CounterStorage

InitCounterStorage to initializer a CounterStorage.

func (*CounterStorage) LoadFromDisk

func (store *CounterStorage) LoadFromDisk(filename string)

LoadFromDisk is Locate the persistent counter from the hard disk and load it into Storage.

func (*CounterStorage) LoadFromString

func (store *CounterStorage) LoadFromString(content string)

LoadFromString is Locate the persistent counter from the String and load it into Storage.

func (*CounterStorage) Save

func (store *CounterStorage) Save(key string, value uint64)

Save the new counter value and persist it. persist is Asynchronous.

type DataStatistical

type DataStatistical interface {
	Handler(ctx echo.Context) error
	Path() string
}

DataStatistical is a basic statistician common implementation interface.

type Kernel

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

Kernel have all huck state.

func NewHuckKernel

func NewHuckKernel() *Kernel

NewHuckKernel to initializer a HuckKernel.

func (*Kernel) ParseConfigHandler

func (hk *Kernel) ParseConfigHandler(conf *Configuration)

ParseConfigHandler is All processors in the parse configuration struct are added to HuckKernel.

func (*Kernel) RegisterHandlerToEcho

func (hk *Kernel) RegisterHandlerToEcho(e *echo.Echo)

RegisterHandlerToEcho is Add all the processors in the HuckKernel to Echo.

type Response

type Response struct {
	Code uint8 `json: "code"`
}

Response is Default huck http response.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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