jupiter

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: Apache-2.0 Imports: 33 Imported by: 88

README

Build Status 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 {
		fmt.Println("now: ", time.Now().Local().String())
		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:
  • Wechat:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	// 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 (*Application) AfterStop

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

func (*Application) BeforeStop

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

func (*Application) Defer

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

Deprecated, use AfterStop instead

func (*Application) GracefulStop

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

GracefulStop application after necessary cleanup

func (*Application) Run

func (app *Application) Run() error

Run run application

func (*Application) Schedule

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

func (*Application) Serve

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

func (*Application) SetGovernor

func (app *Application) SetGovernor(addr string)

SetGovernor governor 127.0.0.1:9990 as default governor addr

func (*Application) SetRegistry

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

SetRegistry set customize registry

func (*Application) SetSignalHooker

func (app *Application) SetSignalHooker(hook func(*Application))

SetSignalHooker set signal hooker

func (*Application) Startup

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

func (*Application) Stop

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

Stop application immediately after necessary cleanup

Jump to

Keyboard shortcuts

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