hippo

package module
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2020 License: MIT Imports: 11 Imported by: 4

README

Hippo V2

Hippo is an easy, fast, lightweight server engine which supports gracefully shutdown.

Build Status

  • powered by Go, Logrus

Hippo

Struct

type SimpleServer struct {
	hippo.Launcher // DO NOT REMOVE; links servers and engines each other.
}

func (s *SimpleServer) Start() error {
	return nil
}

func (s *SimpleServer) Stop() error {
	return nil
}

Run

Simple
engine := hippo.NewEngine(&SimpleServer{}, nil)
if err := engine.Start(); err != nil {
    panic(err)
}
Log to STDOUT
config := &hippo.Config{
    Debug: true,
}
engine := hippo.NewEngine(&SimpleServer{}, config)
if err := engine.Start(); err != nil {
    panic(err)
}
Log to the file
config := &hippo.Config{
    Debug:  true,
    LogDir: ".",
}
engine := hippo.NewEngine(&SimpleServer{}, config)
if err := engine.Start(); err != nil {
    panic(err)
}

Documentation

Overview

Hippo is an easy, fast, lightweight server framework.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorRequiredOption    = errors.New("required option")
	ErrorInvalidTimeFormat = errors.New("invalid time format")
	ErrorInvalidDataFormat = errors.New("invalid data format")
	ErrorDirectoryNotFound = errors.New("directory not found")
)

Functions

func EnsureDir

func EnsureDir(dir string) error

func Usage

func Usage(fs *pflag.FlagSet, description, version string) func()

Types

type Config

type Config struct {
	Name        string
	DisplayName string
	Description string
	Version     string
	LogDir      string
	Debug       bool
	Trace       bool
}

Hippo configuration struct

func NewDefaultConfig

func NewDefaultConfig(processName string) *Config

type Engine

type Engine struct {
	Config *Config

	Log *logrus.Logger
	// contains filtered or unexported fields
}

Engine supports engine framework.

func NewEngine

func NewEngine(server Server, config *Config) *Engine

NewEngine allocates a new server to engine.

func (*Engine) GetContext

func (e *Engine) GetContext() context.Context

func (*Engine) GetWorkingDir

func (e *Engine) GetWorkingDir() string

func (*Engine) Start

func (e *Engine) Start() error

Start starts server and opens error channel.

type Launcher

type Launcher struct {
	Engine *Engine
}

type Server

type Server interface {
	Start() error
	Stop() error
	// contains filtered or unexported methods
}

Directories

Path Synopsis
cmd
1-simple command
2-general command

Jump to

Keyboard shortcuts

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