Documentation
¶
Index ¶
- func SetLogger(l StdLogger)
- type App
- type StdLogger
- type StreamMessenger
- func (m *StreamMessenger) Close() error
- func (m *StreamMessenger) Recv(v interface{}) (err error)
- func (m *StreamMessenger) Send(v interface{}) error
- func (m *StreamMessenger) SetDeadline(t time.Time) error
- func (m *StreamMessenger) SetReadDeadline(t time.Time) error
- func (m *StreamMessenger) SetWriteDeadline(t time.Time) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct {
WaitForParentTimeout time.Duration
WaitForChildTimeout time.Duration
// contains filtered or unexported fields
}
App TODO
type StdLogger ¶
type StdLogger interface {
Print(...interface{})
Printf(string, ...interface{})
Println(...interface{})
Fatal(...interface{})
Fatalf(string, ...interface{})
Fatalln(...interface{})
Panic(...interface{})
Panicf(string, ...interface{})
Panicln(...interface{})
}
StdLogger is an interface for stdlib logger also compatible with logrus
type StreamMessenger ¶
type StreamMessenger struct {
// contains filtered or unexported fields
}
StreamMessenger a simple messenger based on net.Conn. A simplest way to create messenger is to use syscall.Socketpair():
fds, err := syscall.Socketpair(syscall.AF_UNIX, syscall.SOCK_STREAM, 0) f0 := os.NewFile(uintptr(fds[0]), "s|0") f1 := os.NewFile(uintptr(fds[1]), "s|1") m0, err := ListenSocket(f0) m1, err := ListenSocket(f1)
Packet format: +-----------------------+---------+ | Header (8 bytes) | Payload | +-----------------------+---------+ | MagicN | Payload Size | Payload | +-----------------------+---------+
func (*StreamMessenger) Close ¶
func (m *StreamMessenger) Close() error
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*StreamMessenger) Recv ¶
func (m *StreamMessenger) Recv(v interface{}) (err error)
Recv receives a message from the channel.
func (*StreamMessenger) Send ¶
func (m *StreamMessenger) Send(v interface{}) error
Send sends a message to the channel.
func (*StreamMessenger) SetDeadline ¶
func (m *StreamMessenger) SetDeadline(t time.Time) error
SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations fail with a timeout (see type Error) instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out.
func (*StreamMessenger) SetReadDeadline ¶
func (m *StreamMessenger) SetReadDeadline(t time.Time) error
SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.
func (*StreamMessenger) SetWriteDeadline ¶
func (m *StreamMessenger) SetWriteDeadline(t time.Time) error
SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.