rpcplugin

package
v4.2.0-rc2+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2017 License: AGPL-3.0, Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectIOReader

func ConnectIOReader(conn io.ReadWriteCloser) io.ReadCloser

func InheritedIPC

func InheritedIPC(fd0, fd1 uintptr) (io.ReadWriteCloser, error)

Returns the IPC instance inherited by the process from its parent.

func InheritedProcessIPC

func InheritedProcessIPC() (io.ReadWriteCloser, error)

When called on a process launched with NewProcess, returns the inherited IPC.

func Main

func Main(hooks interface{})

Makes a set of hooks available via RPC. This function never returns.

func NewIPC

func NewIPC() (io.ReadWriteCloser, []*os.File, error)

Returns a new IPC for the parent process and a set of files to pass on to the child.

The returned files must be closed after the child process is started.

func NewReadWriteCloser

func NewReadWriteCloser(r io.ReadCloser, w io.WriteCloser) io.ReadWriteCloser

func ServeAPI

func ServeAPI(api plugin.API, conn io.ReadWriteCloser, muxer *Muxer)

func ServeHTTPResponseWriter

func ServeHTTPResponseWriter(w http.ResponseWriter, conn io.ReadWriteCloser)

func ServeHooks

func ServeHooks(hooks interface{}, conn io.ReadWriteCloser, muxer *Muxer)

func ServeIOReader

func ServeIOReader(r io.Reader, conn io.ReadWriteCloser)

func SupervisorProvider

func SupervisorProvider(bundle *model.BundleInfo) (plugin.Supervisor, error)

Types

type APIChannelReply

type APIChannelReply struct {
	Channel *model.Channel
	Error   *model.AppError
}

type APIGetChannelByNameArgs

type APIGetChannelByNameArgs struct {
	Name   string
	TeamId string
}

type APIPostReply

type APIPostReply struct {
	Post  *model.Post
	Error *model.AppError
}

type APITeamReply

type APITeamReply struct {
	Team  *model.Team
	Error *model.AppError
}

type APIUserReply

type APIUserReply struct {
	User  *model.User
	Error *model.AppError
}

type LocalAPI

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

func (*LocalAPI) CreatePost

func (api *LocalAPI) CreatePost(args *model.Post, reply *APIPostReply) error

func (*LocalAPI) GetChannelByName

func (api *LocalAPI) GetChannelByName(args *APIGetChannelByNameArgs, reply *APIChannelReply) error

func (*LocalAPI) GetTeamByName

func (api *LocalAPI) GetTeamByName(args string, reply *APITeamReply) error

func (*LocalAPI) GetUserByUsername

func (api *LocalAPI) GetUserByUsername(args string, reply *APIUserReply) error

func (*LocalAPI) LoadPluginConfiguration

func (api *LocalAPI) LoadPluginConfiguration(args struct{}, reply *[]byte) error

type LocalHTTPResponseWriter

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

func (*LocalHTTPResponseWriter) Header

func (w *LocalHTTPResponseWriter) Header(args struct{}, reply *http.Header) error

func (*LocalHTTPResponseWriter) SyncHeader

func (w *LocalHTTPResponseWriter) SyncHeader(args http.Header, reply *struct{}) error

func (*LocalHTTPResponseWriter) Write

func (w *LocalHTTPResponseWriter) Write(args []byte, reply *struct{}) error

func (*LocalHTTPResponseWriter) WriteHeader

func (w *LocalHTTPResponseWriter) WriteHeader(args int, reply *struct{}) error

type LocalHooks

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

func (*LocalHooks) Implemented

func (h *LocalHooks) Implemented(args struct{}, reply *[]string) error

Implemented replies with the names of the hooks that are implemented.

func (*LocalHooks) OnActivate

func (h *LocalHooks) OnActivate(args int64, reply *struct{}) error

func (*LocalHooks) OnDeactivate

func (h *LocalHooks) OnDeactivate(args, reply *struct{}) (err error)

func (*LocalHooks) ServeHTTP

func (h *LocalHooks) ServeHTTP(args ServeHTTPArgs, reply *struct{}) error

type Muxer

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

Muxer allows multiple bidirectional streams to be transmitted over a single connection.

Muxer is safe for use by multiple goroutines.

Streams opened on the muxer must be periodically drained in order to reclaim read buffer memory. In other words, readers must consume incoming data as it comes in.

func NewMuxer

func NewMuxer(conn io.ReadWriteCloser, parity bool) *Muxer

Creates a new Muxer.

conn must be safe for simultaneous reads by one goroutine and writes by another.

For two muxers communicating with each other via a connection, parity must be true for exactly one of them.

func (*Muxer) Close

func (m *Muxer) Close() error

Closes the muxer.

func (*Muxer) Connect

func (m *Muxer) Connect(id int64) io.ReadWriteCloser

Opens a remotely opened stream.

func (*Muxer) IsClosed

func (m *Muxer) IsClosed() bool

func (*Muxer) Read

func (m *Muxer) Read(p []byte) (int, error)

Calling Read on the muxer directly performs a read on a dedicated, always-open channel.

func (*Muxer) Serve

func (m *Muxer) Serve() (int64, io.ReadWriteCloser)

Opens a new stream with a unique id.

Writes made to the stream before the other end calls Connect will be discarded.

func (*Muxer) Write

func (m *Muxer) Write(p []byte) (int, error)

Calling Write on the muxer directly performs a write on a dedicated, always-open channel.

type Process

type Process interface {
	// Waits for the process to exit and returns an error if a problem occurred or the process exited
	// with a non-zero status.
	Wait() error
}

func NewProcess

func NewProcess(ctx context.Context, path string) (Process, io.ReadWriteCloser, error)

NewProcess launches an RPC executable in a new process and returns an IPC that can be used to communicate with it.

type RemoteAPI

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

func ConnectAPI

func ConnectAPI(conn io.ReadWriteCloser, muxer *Muxer) *RemoteAPI

func (*RemoteAPI) Close

func (h *RemoteAPI) Close() error

func (*RemoteAPI) CreatePost

func (api *RemoteAPI) CreatePost(post *model.Post) (*model.Post, *model.AppError)

func (*RemoteAPI) GetChannelByName

func (api *RemoteAPI) GetChannelByName(name, teamId string) (*model.Channel, *model.AppError)

func (*RemoteAPI) GetTeamByName

func (api *RemoteAPI) GetTeamByName(name string) (*model.Team, *model.AppError)

func (*RemoteAPI) GetUserByUsername

func (api *RemoteAPI) GetUserByUsername(name string) (*model.User, *model.AppError)

func (*RemoteAPI) LoadPluginConfiguration

func (api *RemoteAPI) LoadPluginConfiguration(dest interface{}) error

type RemoteHTTPResponseWriter

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

func ConnectHTTPResponseWriter

func ConnectHTTPResponseWriter(conn io.ReadWriteCloser) *RemoteHTTPResponseWriter

func (*RemoteHTTPResponseWriter) Close

func (h *RemoteHTTPResponseWriter) Close() error

func (*RemoteHTTPResponseWriter) Header

func (w *RemoteHTTPResponseWriter) Header() http.Header

func (*RemoteHTTPResponseWriter) Write

func (w *RemoteHTTPResponseWriter) Write(b []byte) (int, error)

func (*RemoteHTTPResponseWriter) WriteHeader

func (w *RemoteHTTPResponseWriter) WriteHeader(statusCode int)

type RemoteHooks

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

func ConnectHooks

func ConnectHooks(conn io.ReadWriteCloser, muxer *Muxer) (*RemoteHooks, error)

func ConnectMain

func ConnectMain(muxer *Muxer) (*RemoteHooks, error)

Returns the hooks being served by a call to Main.

func (*RemoteHooks) Close

func (h *RemoteHooks) Close() error

func (*RemoteHooks) Implemented

func (h *RemoteHooks) Implemented() (impl []string, err error)

func (*RemoteHooks) OnActivate

func (h *RemoteHooks) OnActivate(api plugin.API) error

func (*RemoteHooks) OnDeactivate

func (h *RemoteHooks) OnDeactivate() error

func (*RemoteHooks) ServeHTTP

func (h *RemoteHooks) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RemoteIOReader

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

func (*RemoteIOReader) Close

func (r *RemoteIOReader) Close() error

func (*RemoteIOReader) Read

func (r *RemoteIOReader) Read(b []byte) (int, error)

type ServeHTTPArgs

type ServeHTTPArgs struct {
	ResponseWriterStream int64
	Request              *http.Request
	RequestBodyStream    int64
}

type Supervisor

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

Supervisor implements a plugin.Supervisor that launches the plugin in a separate process and communicates via RPC.

If the plugin unexpectedly exists, the supervisor will relaunch it after a short delay.

func (*Supervisor) Hooks

func (s *Supervisor) Hooks() plugin.Hooks

Returns the hooks used to communicate with the plugin. The hooks may change if the plugin is restarted, so the return value should not be cached.

func (*Supervisor) Start

func (s *Supervisor) Start() error

Starts the plugin. This method will block until the plugin is successfully launched for the first time and will return an error if the plugin cannot be launched at all.

func (*Supervisor) Stop

func (s *Supervisor) Stop() error

Stops the plugin.

Jump to

Keyboard shortcuts

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