service

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: BSD-2-Clause Imports: 20 Imported by: 7

Documentation

Index

Constants

View Source
const (
	StatusStopped = iota + 1
	StatusStarted
	StatusStarting
)

Variables

View Source
var (
	DefaultGrpcDialer   = netConn
	DefaultGrpcListener = netConn
	DefaultHTTPListener = netConn
	DefaultHTTPClient   = netConn
)
View Source
var (
	ErrOtelStack  = errors.New("obs.New: error initializing otel stack")
	ErrEnvLoading = errors.New("env.Populate: error initializing otel stack")
)
View Source
var ErrEmptyAddress = errors.New("address is empty")

Functions

func AttachProfilingHandlers added in v0.5.0

func AttachProfilingHandlers(router *mux.Router)

Types

type Base added in v0.5.0

type Base struct {
	Meta *meta.Data

	HnUpTime     string
	Addr         string
	OtelProvider *obs.OtelProvider
	Ctx          context.Context
	// contains filtered or unexported fields
}

Base provides common functionality for processes that run in background.

func New added in v0.5.0

func New(opts ...Option) (*Base, error)

func (*Base) Metadata added in v0.5.0

func (s *Base) Metadata() map[string]string

func (*Base) Name added in v0.5.0

func (s *Base) Name() string

func (*Base) SetStartedNow added in v0.5.0

func (s *Base) SetStartedNow()

func (*Base) Status added in v0.6.0

func (s *Base) Status() (string, time.Time)

func (*Base) Stop added in v0.5.0

func (s *Base) Stop()

func (*Base) Stopped added in v0.5.0

func (s *Base) Stopped()

type BufConn added in v0.5.0

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

func NewBufConn added in v0.5.0

func NewBufConn() *BufConn

func NewBufConnWithTimeout added in v0.5.0

func NewBufConnWithTimeout(timeout time.Duration) *BufConn

func (*BufConn) Close added in v0.5.0

func (t *BufConn) Close(addr string) error

func (*BufConn) CloseAll added in v0.5.0

func (t *BufConn) CloseAll()

func (*BufConn) Dial added in v0.5.0

func (t *BufConn) Dial(_ context.Context, addr string) (*rpc.ClientConn, error)

func (*BufConn) Listen added in v0.5.0

func (t *BufConn) Listen(addr string) (net.Listener, error)

func (*BufConn) NewHTTPClient added in v0.5.0

func (t *BufConn) NewHTTPClient(addr string) (*http.Client, error)

func (*BufConn) Tranport added in v0.5.0

func (t *BufConn) Tranport(addr string) (*http.Transport, error)

type ErrNotHealthy added in v0.5.0

type ErrNotHealthy struct {
	Addr string
}

func (ErrNotHealthy) Error added in v0.5.0

func (e ErrNotHealthy) Error() string

type GrpcConn added in v0.5.0

type GrpcConn struct {
	Dialer   GrpcDialer
	Listener GrpcListener
}

type GrpcDialer added in v0.5.0

type GrpcDialer interface {
	Dial(ctx context.Context, addr string) (*rpc.ClientConn, error)
}

type GrpcListener added in v0.5.0

type GrpcListener interface {
	Listen(addr string) (net.Listener, error)
}

type HTTPClientBuilder added in v0.5.0

type HTTPClientBuilder interface {
	NewHTTPClient(addr string) (*http.Client, error)
}

type HTTPConn added in v0.5.0

type HTTPConn struct {
	ClientBuilder HTTPClientBuilder
	Listener      HTTPListener
}

func (HTTPConn) ClientBuilderOrDefault added in v0.5.0

func (s HTTPConn) ClientBuilderOrDefault() HTTPClientBuilder

func (HTTPConn) ListenerOrDefault added in v0.5.0

func (s HTTPConn) ListenerOrDefault() HTTPListener

type HTTPListener added in v0.5.0

type HTTPListener interface {
	Listen(addr string) (net.Listener, error)
}

type HTTPTranporter added in v0.5.0

type HTTPTranporter interface {
	Tranport(addr string) (*http.Transport, error)
}

type HealthChecker added in v0.5.0

type HealthChecker interface {
	CheckOk(ctx context.Context) error
	Close() error
}

type HealthStatus added in v0.6.0

type HealthStatus struct {
	Status        string `json:"status"`
	ServiceStatus string `json:"service_status"`
	StartedAt     string `json:"started_at"`
	Error         error
	Details       map[string]string `json:"details"`
}

type Kind added in v0.5.0

type Kind int
const (
	GRPC Kind = iota + 1
	HTTP
	Process
)

type ListenerFn added in v0.5.0

type ListenerFn func(ctx context.Context, addr string) (net.Listener, error)

type NetConn added in v0.5.0

type NetConn struct{}

func (NetConn) Dial added in v0.5.0

func (NetConn) Dial(_ context.Context, addr string) (*rpc.ClientConn, error)

func (NetConn) Listen added in v0.5.0

func (NetConn) Listen(addr string) (net.Listener, error)

func (NetConn) NewHTTPClient added in v0.5.0

func (NetConn) NewHTTPClient(_ string) (*http.Client, error)

type Option added in v0.5.0

type Option func(*Base)

func WithAddr added in v0.5.0

func WithAddr(addr string) Option

func WithContext added in v0.5.0

func WithContext(ctx context.Context) Option

func WithKind added in v0.5.0

func WithKind(kind string) Option

func WithMetaInfo added in v0.5.0

func WithMetaInfo(meta *meta.Data) Option

Setters

func WithName added in v0.5.0

func WithName(name string) Option

func WithOtelProvider added in v0.5.0

func WithOtelProvider(p *obs.OtelProvider) Option

type StatusType added in v0.6.0

type StatusType int

func (StatusType) String added in v0.6.0

func (s StatusType) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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