graceful

package
v0.0.0-...-32b1917 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompleteResult

type CompleteResult struct {
	Success bool
	Error   error
}

type IApplication

type IApplication interface {
	SetName(value string)
	GetName() string

	SetCmd(value string)
	GetCmd() string

	SetPrintCh(value chan string)
	GetPrintCh() chan string

	SetWorkPath(value string)
	GetWorkPath() string

	SetTimeOut(value time.Duration)
	GetTimeOut() time.Duration

	SetContext(ctx context.Context)
	GetContext() context.Context

	Run(args ...string) error
}

func NewIApplication

func NewIApplication(opts ...Option) IApplication

NewIApplication create an application

Example
app := NewIApplication(
	WithCmd("go"),
	WithPrintCh(),
	WithName("go应用"),
	WithContext(context.Background()),
	WithWorkPath("./"),
	WithTimeOut(5*time.Second))
err := app.Run("env")
if err != nil {
	fmt.Print(err)
}
Output:

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithCmd

func WithCmd(cmd string) Option

WithCmd out app call command

func WithContext

func WithContext(ctx context.Context) Option

WithContext run context

func WithName

func WithName(name string) Option

WithName named application

func WithPrintCh

func WithPrintCh() Option

WithPrintCh use output chan, if nil then use std

func WithTimeOut

func WithTimeOut(timeout time.Duration) Option

WithTimeOut work must in set time

func WithWorkPath

func WithWorkPath(wPath string) Option

WithWorkPath work dir path

type Server

type Server struct {
	Name   string
	Ip     string
	Port   int
	Engine *gin.Engine
}

func New

func New() *Server

func (*Server) Start

func (s *Server) Start()

Jump to

Keyboard shortcuts

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