hyper

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 18 Imported by: 0

README

Hyper

Hyper is a lightweight and easy-to-use framework. The hyper framework works out of the box. It has built-in commonly used components, you only need to turn it on according to your needs.

Feature

  • Based on gin framework, Lightweight and easy to use
  • Config
    • Based on spf13/viper package
    • Support local files (yaml format) and consul
  • Logger
    • Base on sirupsen/logrus package
    • Support multiple output sources (stdout/stderr/file)
    • Support text or json format log output
  • Queue
    • Support redis and kafka two types of queue storage backend
    • Ability to recover from abnormal consumption tasks
    • Support consumer task failure retry function
    • Built-in prometheus exporter, you can review your queue
  • Mysql
    • Base on go-gorm/gorm package
    • The maximum number of connections, enable sql log and other settings only need to be configured
  • Discover
    • Support Consul-based service registration and discovery
  • Selector
    • Support getting nodes from Discover for load balancing
    • Support RoundRobin strategy
  • Cache
    • Support redis as a storage backend
  • Built-in performance analysis tool pprof

Install and Use

Install
go get -u github.com/cyub/hyper/cmd/hyper@v1.1.0
Create Application
cd www/
hyper new your_project_name
Run Application
cd your_project_name
make run

If an error message like github.com/coreos/etcd@v3.3.10+incompatible/client/keys.generated.go:63:14: z.HasExtensions appears during operation, remove this keys.generated.go file to solve the problem

Access Application
curl localhost:8000/welcome

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCronJob added in v1.1.0

func AddCronJob(spec string, cmd func())

AddCronJob use add cron job

func Cache

func Cache() cache.Cache

Cache return cache.Cache

func Config

func Config() *config.Config

Config return config.Config

func DB

func DB() *gorm.DB

DB return gorm.DB

func InQueue

func InQueue(name string, data interface{}) error

InQueue use for job enqueue

func InQueueWithRetry

func InQueueWithRetry(name string, data interface{}, tries int) error

InQueueWithRetry use for job enqueue

func Logger

func Logger() *logrus.Logger

Logger return logrus.Logger

func NewApp

func NewApp(opts ...app.Option) *app.App

NewApp return application

func NewJob

func NewJob(name string, data interface{}, tries int) (*queue.Job, error)

NewJob return job

func Queue

func Queue() queue.Queuer

Queue return queue.Queue

func Redis

func Redis() *redis.Client

Redis return redis.Client

func RedisCluster

func RedisCluster() *redis.ClusterClient

RedisCluster return redis.ClusterClient

func Registry added in v1.1.0

func Registry() registry.Registry

Registry return registry.Registry

func WithAddr

func WithAddr(addr string) app.Option

WithAddr use for set app's addr

func WithCfgAddr

func WithCfgAddr(cfgAddr string) app.Option

WithCfgAddr use for set app's config center addr

func WithCfgPath

func WithCfgPath(cfgPath string) app.Option

WithCfgPath use for set app's config center path

func WithCron added in v1.1.0

func WithCron(cron *cron.Cron) app.Option

WithCron use for set user defined cron object

func WithCronEnable added in v1.1.0

func WithCronEnable() app.Option

WithCronEnable use for enable cron. default is disable

func WithHideBanner

func WithHideBanner() app.Option

WithHideBanner use for set hide hyper banner

func WithName

func WithName(name string) app.Option

WithName use for set app's name

func WithRunMode

func WithRunMode(mode string) app.Option

WithRunMode use for set app's run mode

Types

This section is empty.

Jump to

Keyboard shortcuts

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