Documentation
¶
Overview ¶
Package notifier defines the interface and the GRPC implementation for event notifier plugins. Notifier plugins allow to receive notifications for supported filesystem events such as file uploads, downloads etc. and provider events such as objects add, update, delete.
Index ¶
Constants ¶
const (
// PluginName defines the name for a notifier plugin
PluginName = "notifier"
)
Variables ¶
var Handshake = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "SFTPGO_PLUGIN_NOTIFIER",
MagicCookieValue: "c499b98b-cd59-4df2-92b3-6268817f4d80",
}
Handshake is a common handshake that is shared by plugin and host.
var PluginMap = map[string]plugin.Plugin{ PluginName: &Plugin{}, }
PluginMap is the map of plugins we can dispense.
Functions ¶
This section is empty.
Types ¶
type FsEvent ¶
type FsEvent struct {
Action string `json:"action"`
Username string `json:"username"`
Path string `json:"path"`
TargetPath string `json:"target_path,omitempty"`
VirtualPath string `json:"virtual_path"`
VirtualTargetPath string `json:"virtual_target_path,omitempty"`
SSHCmd string `json:"ssh_cmd,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
FsProvider int `json:"fs_provider"`
Bucket string `json:"bucket,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
Status int `json:"status"`
Protocol string `json:"protocol"`
IP string `json:"ip"`
SessionID string `json:"session_id"`
Timestamp int64 `json:"timestamp"`
OpenFlags int `json:"open_flags,omitempty"`
}
FsEvent defines a file system event
type GRPCClient ¶
type GRPCClient struct {
// contains filtered or unexported fields
}
GRPCClient is an implementation of Notifier interface that talks over RPC.
func (*GRPCClient) NotifyFsEvent ¶
func (c *GRPCClient) NotifyFsEvent(event *FsEvent) error
NotifyFsEvent implements the Notifier interface
func (*GRPCClient) NotifyProviderEvent ¶
func (c *GRPCClient) NotifyProviderEvent(event *ProviderEvent) error
NotifyProviderEvent implements the Notifier interface
type GRPCServer ¶
type GRPCServer struct {
Impl Notifier
}
GRPCServer defines the gRPC server that GRPCClient talks to.
func (*GRPCServer) SendFsEvent ¶
SendFsEvent implements the serve side fs notify method
func (*GRPCServer) SendProviderEvent ¶
func (s *GRPCServer) SendProviderEvent(ctx context.Context, req *proto.ProviderEvent) (*emptypb.Empty, error)
SendProviderEvent implements the serve side provider event notify method
type Notifier ¶
type Notifier interface {
NotifyFsEvent(event *FsEvent) error
NotifyProviderEvent(event *ProviderEvent) error
}
Notifier defines the interface for notifiers plugins
type Plugin ¶
Plugin defines the implementation to serve/connect to a notifier plugin
func (*Plugin) GRPCClient ¶
func (p *Plugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
GRPCClient defines the GRPC client implementation for this plugin
func (*Plugin) GRPCServer ¶
GRPCServer defines the GRPC server implementation for this plugin