-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.go
More file actions
35 lines (31 loc) · 944 Bytes
/
Copy pathplugin.go
File metadata and controls
35 lines (31 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package gosdk
import (
"context"
api "github.com/begonia-org/go-sdk/api/plugin/v1"
"google.golang.org/grpc"
)
type Plugin interface {
SetPriority(priority int)
Priority() int
Name() string
}
type LocalPlugin interface {
Plugin
UnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error)
StreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
StreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)
}
type RemotePlugin interface {
Plugin
api.PluginServiceClient
}
type Plugins []Plugin
func (p Plugins) Len() int {
return len(p)
}
func (p Plugins) Swap(i, j int) {
p[i], p[j] = p[j], p[i]
}
func (p Plugins) Less(i, j int) bool {
return p[i].Priority() > p[j].Priority()
}