Browse Source

unbuffer channels, add SendRaw()

main
David Haukeness 2 years ago
parent
commit
0e1efc282d
  1. 19
      keybase.go

19
keybase.go

@ -85,9 +85,9 @@ type KeybaseAPIResponse struct { @@ -85,9 +85,9 @@ type KeybaseAPIResponse struct {
func NewAPI(options *Options) *ChatAPI {
return &ChatAPI{
opts: options,
inChan: make(chan []byte, 10),
outChan: make(chan []byte, 10),
errChan: make(chan error, 10),
inChan: make(chan []byte),
outChan: make(chan []byte),
errChan: make(chan error),
}
}
@ -109,6 +109,19 @@ func (a *ChatAPI) Start(ctx context.Context) error { @@ -109,6 +109,19 @@ func (a *ChatAPI) Start(ctx context.Context) error {
return nil
}
// SendRaw sends raw JSON bytes to the API without helper functions
func (a *ChatAPI) SendRaw(msg []byte) ([]byte, error) {
a.Lock()
defer a.Unlock()
a.inChan <- msg
select {
case err := <-a.errChan:
return nil, err
case resp := <-a.outChan:
return resp, nil
}
}
// CmdPipe holds the pipes that connect to the long-running keybase api commands
type CmdPipe struct {
Stderr io.ReadCloser

Loading…
Cancel
Save