stdconn

package
v0.0.2-0...-1c7e8a7 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: Unlicense Imports: 7 Imported by: 0

README

StdConn

This is a simple library that runs a client executable (in the example, it uses go run), creates a net.Conn with the stdin/stdout on both sides so the controller process can send IPC messages

How to use

stdconn.go and worker/worker.go are the reusable/convenience parts . stdconn.go is the net.Conn implementation and worker.go is mainly just a helper to start up an arbitrary executable with arbitrary arguments, it also has helpers to send stop and kill signals.

hello/implementation.go contains an example RPC implementation. Note that the most basic implementation should have a function like Bye() to stop the client, as closing its connection when using this IPC mechanism does not stop the child process which will block unless it is explicitly killed, and using os.Signal requires adding this handling code. So they are there for defcon IV type situations mainly and if using signals is preferred.

hello/wrapper contains a set of wrappers that shortens the RPC call syntax. If asynchronous calling is required, the wrappers would mimic the calling pattern with a cancel function and function that returns the reply or error over a channel. Probably this could be automated somehow but I haven't got the need or time for that right now.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(err error) bool

func Debug

func Debug(a ...interface{})

func Debugc

func Debugc(fn func() string)

func Debugf

func Debugf(format string, a ...interface{})

func Debugs

func Debugs(a interface{})

func Error

func Error(a ...interface{})

func Errorc

func Errorc(fn func() string)

func Errorf

func Errorf(format string, a ...interface{})

func Errors

func Errors(a interface{})

func Fatal

func Fatal(a ...interface{})

func Fatalc

func Fatalc(fn func() string)

func Fatalf

func Fatalf(format string, a ...interface{})

func Fatals

func Fatals(a interface{})

func Info

func Info(a ...interface{})

func Infoc

func Infoc(fn func() string)

func Infof

func Infof(format string, a ...interface{})

func Infos

func Infos(a interface{})

func Trace

func Trace(a ...interface{})

func Tracec

func Tracec(fn func() string)

func Tracef

func Tracef(format string, a ...interface{})

func Traces

func Traces(a interface{})

func Warn

func Warn(a ...interface{})

func Warnc

func Warnc(fn func() string)

func Warnf

func Warnf(format string, a ...interface{})

func Warns

func Warns(a interface{})

Types

type StdConn

type StdConn struct {
	io.ReadCloser
	io.WriteCloser
	Quit qu.C
}

func New

func New(in io.ReadCloser, out io.WriteCloser, quit qu.C) (s *StdConn)

func (*StdConn) Close

func (s *StdConn) Close() (err error)

func (*StdConn) LocalAddr

func (s *StdConn) LocalAddr() (addr net.Addr)

func (*StdConn) Read

func (s *StdConn) Read(b []byte) (n int, err error)

func (*StdConn) RemoteAddr

func (s *StdConn) RemoteAddr() (addr net.Addr)

func (*StdConn) SetDeadline

func (s *StdConn) SetDeadline(t time.Time) (err error)

func (*StdConn) SetReadDeadline

func (s *StdConn) SetReadDeadline(t time.Time) (err error)

func (*StdConn) SetWriteDeadline

func (s *StdConn) SetWriteDeadline(t time.Time) (err error)

func (*StdConn) Write

func (s *StdConn) Write(b []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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