github.com/Unheilbar/quorum@v1.0.0/plugin/qlight/gateway.go (about) 1 package qlight 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/ConsenSys/quorum-qlight-token-manager-plugin-sdk-go/proto" 8 ) 9 10 type PluginGateway struct { 11 client proto.PluginQLightTokenRefresherClient 12 } 13 14 var _ PluginTokenManager = &PluginGateway{} 15 16 func (p *PluginGateway) TokenRefresh(ctx context.Context, currentToken, psi string) (string, error) { 17 resp, err := p.client.TokenRefresh(ctx, &proto.TokenRefresh_Request{ 18 CurrentToken: currentToken, 19 Psi: psi, 20 }) 21 if err != nil { 22 return "", fmt.Errorf("refresh token: %w", err) 23 } 24 return resp.Token, nil 25 } 26 27 func (p *PluginGateway) PluginTokenManager(ctx context.Context) (int32, error) { 28 resp, err := p.client.PluginQLightTokenManager(ctx, &proto.PluginQLightTokenManager_Request{}) 29 if err != nil { 30 return 0, fmt.Errorf("refresh token: %w", err) 31 } 32 return resp.RefreshAnticipationInMillisecond, nil 33 }