daemonutil

package
v0.0.0-...-9474aff Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package daemonutil provides utilities for controlling background processes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReadyFunc

type ReadyFunc func([]byte) (bool, error)

ReadyFunc checks the data written to ReadyWriter and returns if the service is ready or having error. ReadyWriter expects:

(false, nil) if the service is not ready yet;
(false, err) if the service has an error;
(true, nil) if the service is ready.

type ReadyWriter

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

ReadyWriter stores the data written to it and identifies if a service is ready or already failed.

func NewReadyWriter

func NewReadyWriter(f ReadyFunc) *ReadyWriter

NewReadyWriter creates a ReadyWriter object with f to detect the state of the service.

func (*ReadyWriter) Close

func (w *ReadyWriter) Close() error

Close closes the writer and emits error if it has not yet detected ready/error event. It implements io.Closer interface.

func (*ReadyWriter) Wait

func (w *ReadyWriter) Wait(ctx context.Context) error

Wait waits until the service is ready or some errors happens.

func (*ReadyWriter) Write

func (w *ReadyWriter) Write(p []byte) (int, error)

Write writes p to the buffer to detect the ready/error event of the service. It implements io.Writer interface.

Jump to

Keyboard shortcuts

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