jupiter

package module
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: Apache-2.0 Imports: 29 Imported by: 88

README

GoTest codecov go.dev reference Go Report Card license

JUPITER: Governance-oriented Microservice Framework

Introduction

JUPITER is a governance-oriented microservice framework, which is being used for years at Douyu.

Documentation

See the 中文文档 for the Chinese documentation.

Quick Start

func main() {
	var app jupiter.Application
	app.Startup()
	app.Serve(startHTTPServer())
	app.Serve(startGRPCServer())
	app.Schedule(startWorker())
	app.Run()
}

func startHTTPServer() server.Server {
	server := xecho.DefaultConfig().Build()
	server.GET("/hello", func(ctx echo.Context) error {
		return ctx.JSON(200, "Gopher Wuhan")
	})
	return server
}

func startGRPCServer() server.Server {
	server := xgrpc.DefaultConfig().Build()
	helloworld.RegisterGreeterServer(server.Server, new(greeter.Greeter))
	return server
}

func startWorker() worker.Worker {
	cron := xcron.DefaultConfig().Build()
	cron.Schedule(xcron.Every(time.Second*10), xcron.FuncJob(func() error {
		return nil
	}))
	return cron
}

More Example:

Bugs and Feedback

For bug report, questions and discussions please submit an issue.

Contributing

Contributions are always welcomed! Please see CONTRIBUTING for detailed guidelines.

You can start with the issues labeled with good first issue.

Contact

  • DingTalk:

Documentation

Index

Constants

View Source
const (
	//StageAfterStop after app stop
	StageAfterStop uint32 = iota + 1
	//StageBeforeStop before app stop
	StageBeforeStop
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	HideBanner bool
	// contains filtered or unexported fields
}

Application is the framework's instance, it contains the servers, workers, client and configuration settings. Create an instance of Application, by using &Application{}

func DefaultApp added in v0.2.4

func DefaultApp() *Application

func New added in v0.2.0

func New(fns ...func() error) (*Application, error)

New new a Application

func (*Application) GracefulStop

func (app *Application) GracefulStop(ctx context.Context) (err error)

GracefulStop application after necessary cleanup

func (*Application) Job added in v0.2.0

func (app *Application) Job(runner job.Runner) error

Job ..

func (*Application) RegisterHooks added in v0.2.0

func (app *Application) RegisterHooks(k uint32, fns ...func() error) error

RegisterHooks register a stage Hook

func (*Application) Run

func (app *Application) Run(servers ...server.Server) error

Run run application

func (*Application) Schedule

func (app *Application) Schedule(w worker.Worker) error

Schedule ..

func (*Application) Serve

func (app *Application) Serve(s ...server.Server) error

Serve start server

func (*Application) SetRegistry

func (app *Application) SetRegistry(reg registry.Registry)

SetRegistry set customize registry

func (*Application) Startup

func (app *Application) Startup(fns ...func() error) error

Startup ..

func (*Application) Stop

func (app *Application) Stop() (err error)

Stop application immediately after necessary cleanup

func (*Application) WithOptions added in v0.2.4

func (a *Application) WithOptions(options ...Option)

type Disable added in v0.2.4

type Disable int
const (
	DisableParserFlag      Disable = 1
	DisableLoadConfig      Disable = 2
	DisableDefaultGovernor Disable = 3
)

type Option added in v0.2.4

type Option func(a *Application)

func WithConfigParser added in v0.2.4

func WithConfigParser(unmarshaller conf.Unmarshaller) Option

func WithDisable added in v0.2.4

func WithDisable(d Disable) Option

Directories

Path Synopsis
cmd
jupiter Module
example module
job
pkg
util/xbuffer
Package buffer provides an implementation of an unbounded buffer.
Package buffer provides an implementation of an unbounded buffer.
util/xtime
https://github.com/siddontang/go/tree/master/time2
https://github.com/siddontang/go/tree/master/time2
util/xgeneric Module
test
e2e Module
tools
jupiter Module

Jump to

Keyboard shortcuts

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