mirror of
https://github.com/xaionaro-go/streamctl.git
synced 2025-10-06 07:56:55 +08:00
Initial commit, pt. 39
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamd/api"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamd/config"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamd/grpc/go/streamd_grpc"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streampanel/consts"
|
||||
)
|
||||
|
||||
type GRPCServer struct {
|
||||
@@ -474,3 +475,31 @@ func (grpc *GRPCServer) SubscribeToOAuthRequests(
|
||||
func (grpc *GRPCServer) OpenOAuthURL(authURL string) {
|
||||
grpc.OAuthURLBroadcaster.Submit(authURL)
|
||||
}
|
||||
|
||||
func (grpc *GRPCServer) GetVariable(
|
||||
ctx context.Context,
|
||||
req *streamd_grpc.GetVariableRequest,
|
||||
) (*streamd_grpc.GetVariableReply, error) {
|
||||
key := consts.VarKey(req.GetKey())
|
||||
b, err := grpc.StreamD.GetVariable(ctx, key)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to get variable '%s': %w", key, err)
|
||||
}
|
||||
|
||||
return &streamd_grpc.GetVariableReply{
|
||||
Key: string(key),
|
||||
Value: b,
|
||||
}, nil
|
||||
}
|
||||
func (grpc *GRPCServer) SetVariable(
|
||||
ctx context.Context,
|
||||
req *streamd_grpc.SetVariableRequest,
|
||||
) (*streamd_grpc.SetVariableReply, error) {
|
||||
key := consts.VarKey(req.GetKey())
|
||||
err := grpc.StreamD.SetVariable(ctx, key, req.GetValue())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to set variable '%s': %w", key, err)
|
||||
}
|
||||
|
||||
return &streamd_grpc.SetVariableReply{}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user