base

package
v0.0.0-...-95c39c8 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LogAdapter = &LoggingAdapter{
		Debugf: func(format string, v ...interface{}) { log.Printf("DEBUG: "+format, v...) },
		Infof:  func(format string, v ...interface{}) { log.Printf("INFO: "+format, v...) },
		Warnf:  func(format string, v ...interface{}) { log.Printf("WARN: "+format, v...) },
		Errorf: func(format string, v ...interface{}) { log.Printf("ERROR: "+format, v...) },
		Fatalf: func(format string, v ...interface{}) { log.Fatalf("FATAL: "+format, v...) },
		Panicf: func(format string, v ...interface{}) { log.Panicf("FATAL: "+format, v...) },
	}

	GLogAdapter = &LoggingAdapter{
		Debugf: glog.V(2).Infof,
		Infof:  glog.V(1).Infof,
		Warnf:  glog.Warningf,
		Errorf: glog.Errorf,
		Fatalf: glog.Fatalf,
		Panicf: func(format string, v ...interface{}) {
			s := fmt.Sprintf(format, v...)

			glog.ErrorDepth(1, s)

			panic(s)
		},
	}
)
View Source
var (
	ErrSubscriberNotFound = errors.New("subscriber not found")
)

Functions

This section is empty.

Types

type App

type App interface {
	Run(args []string) error
}

type AppLifeCycleAware

type AppLifeCycleAware interface {
	OnInit(app App)

	PreMain(app App)

	PostMain(app App)

	OnExit(app App)
}

type AppSlots

type AppSlots struct {
	OnInit   Slot
	PreMain  Slot
	PostMain Slot
	OnExit   Slot
}

type BaseApp

type BaseApp struct {
	Slots AppSlots

	Main func() error
}

func (*BaseApp) Run

func (a *BaseApp) Run(args []string) error

type BaseService

type BaseService struct {
	Serve func() error
	Slots ServiceSlots
	// contains filtered or unexported fields
}

func NewBaseService

func NewBaseService(name string) *BaseService

func (*BaseService) Name

func (s *BaseService) Name() string

func (*BaseService) Start

func (s *BaseService) Start() error

func (*BaseService) Started

func (s *BaseService) Started() bool

func (*BaseService) Stop

func (s *BaseService) Stop() error

type Bootstrap

type Bootstrap struct {
	// contains filtered or unexported fields
}

func NewBootstrap

func NewBootstrap(name string) *Bootstrap

func (*Bootstrap) Build

func (b *Bootstrap) Build(build int) *Bootstrap

func (*Bootstrap) GLog

func (b *Bootstrap) GLog() *Bootstrap

func (*Bootstrap) LogOutput

func (b *Bootstrap) LogOutput(w io.Writer) *Bootstrap

func (*Bootstrap) LogPrefix

func (b *Bootstrap) LogPrefix(prefix string) *Bootstrap

func (*Bootstrap) Major

func (b *Bootstrap) Major(major int) *Bootstrap

func (*Bootstrap) Minor

func (b *Bootstrap) Minor(minor int) *Bootstrap

func (*Bootstrap) Revision

func (b *Bootstrap) Revision(rev string) *Bootstrap

func (*Bootstrap) Syslog

func (b *Bootstrap) Syslog() *Bootstrap

func (*Bootstrap) SyslogDial

func (b *Bootstrap) SyslogDial(uri *url.URL) *Bootstrap

func (*Bootstrap) Version

func (b *Bootstrap) Version(major, minor, build int) *Bootstrap

type Context

type Context context.Context

type ContextAware

type ContextAware interface {
	SetContext(ctxt Context)
}

type LogfFunc

type LogfFunc func(format string, v ...interface{})

type LoggingAdapter

type LoggingAdapter struct {
	Debugf, Infof, Warnf, Errorf, Fatalf, Panicf LogfFunc
}

type Service

type Service interface {
	Name() string

	Started() bool

	Start() error

	Stop() error
}

type ServiceLifecycleAware

type ServiceLifecycleAware interface {
	OnStart(svc Service)

	PreServe(svc Service)

	PostServe(svc Service)

	OnStop(svc Service)
}

type ServiceSlots

type ServiceSlots struct {
	OnStart   Slot
	PreServe  Slot
	PostServe Slot
	OnStop    Slot
}

type ServiceStatus

type ServiceStatus int32
const (
	ServiceUnused ServiceStatus = iota
	ServiceStarted
	ServiceStopped
)

func (ServiceStatus) String

func (s ServiceStatus) String() string

type Slot

type Slot struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Slot) NotifyAll

func (s *Slot) NotifyAll()

func (*Slot) On

func (s *Slot) On(callback func(Value))

func (*Slot) Once

func (s *Slot) Once(callback func(Value))

func (*Slot) Publish

func (s *Slot) Publish(v Value)

func (*Slot) Subscribe

func (s *Slot) Subscribe() Subscriber

type Subscriber

type Subscriber interface {
	Unsubscribe() error

	Chan() chan Value

	Value() Value
}

type Value

type Value interface{}

type Version

type Version struct {
	Major   int
	Minor   int
	Build   int
	Revison string
}

func (*Version) String

func (v *Version) String() string

Jump to

Keyboard shortcuts

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