pipewatcher

package
v0.0.0-...-507ffb6 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package pipewatcher implements a generic pipe event watcher. This watcher will create/trigger an event when a pipe is opened for reading.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handle

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

Handle is the event watcher implementation.

func New

func New(watcherID string, opts Options) *Handle

New allocates and initializes a new Watcher.

func (*Handle) Events

func (hdl *Handle) Events() []string

Events returns an slice with all implemented events.

func (*Handle) ID

func (hdl *Handle) ID() string

ID returns the event watcher id.

func (*Handle) Run

func (hdl *Handle) Run(ctx context.Context, evType string) (bool, any, error)

Run listens to the watcher's pipe open calls and report back the event.

type Options

type Options struct {
	// PipePath is the pipe path.
	PipePath string
	// Mode is the pipe mode.
	Mode uint32
	// ReadEventID is the event id for the read event.
	ReadEventID string
}

Options are the watcher's extra options.

type PipeData

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

PipeData wraps the pipe event data.

func NewPipeData

func NewPipeData(file *os.File, finishedCb func()) *PipeData

NewPipeData allocates and initializes a new PipeData.

func (*PipeData) Close

func (pd *PipeData) Close() error

Close closes the pipe.

func (*PipeData) Finished

func (pd *PipeData) Finished()

Finished is a callback used by the event handler to inform the write to the pipe is finished.

func (*PipeData) WriteString

func (pd *PipeData) WriteString(data string) (int, error)

WriteString writes the data to the pipe.

Jump to

Keyboard shortcuts

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