TUN-5697: Listen for UpdateConfiguration RPC in quic transport
This commit is contained in:
parent
d78a5ba5da
commit
e56c4532ce
|
@ -265,8 +265,8 @@ func (q *QUICConnection) UnregisterUdpSession(ctx context.Context, sessionID uui
|
|||
}
|
||||
|
||||
// UpdateConfiguration is the RPC method invoked by edge when there is a new configuration
|
||||
func (q *QUICConnection) UpdateConfiguration(ctx context.Context, version int32, config []byte) (*tunnelpogs.UpdateConfigurationResponse, error) {
|
||||
return nil, fmt.Errorf("TODO: TUN-5698")
|
||||
func (q *QUICConnection) UpdateConfiguration(ctx context.Context, version int32, config []byte) *tunnelpogs.UpdateConfigurationResponse {
|
||||
return q.orchestrator.UpdateConfig(version, config)
|
||||
}
|
||||
|
||||
// streamReadWriteAcker is a light wrapper over QUIC streams with a callback to send response back to
|
||||
|
|
|
@ -231,14 +231,18 @@ type mockConfigRPCServer struct {
|
|||
config []byte
|
||||
}
|
||||
|
||||
func (s mockConfigRPCServer) UpdateConfiguration(_ context.Context, version int32, config []byte) (*tunnelpogs.UpdateConfigurationResponse, error) {
|
||||
func (s mockConfigRPCServer) UpdateConfiguration(_ context.Context, version int32, config []byte) *tunnelpogs.UpdateConfigurationResponse {
|
||||
if s.version != version {
|
||||
return nil, fmt.Errorf("expect version %d, got %d", s.version, version)
|
||||
return &tunnelpogs.UpdateConfigurationResponse{
|
||||
Err: fmt.Errorf("expect version %d, got %d", s.version, version),
|
||||
}
|
||||
}
|
||||
if !bytes.Equal(s.config, config) {
|
||||
return nil, fmt.Errorf("expect config %v, got %v", s.config, config)
|
||||
return &tunnelpogs.UpdateConfigurationResponse{
|
||||
Err: fmt.Errorf("expect config %v, got %v", s.config, config),
|
||||
}
|
||||
return &tunnelpogs.UpdateConfigurationResponse{LastAppliedVersion: version}, nil
|
||||
}
|
||||
return &tunnelpogs.UpdateConfigurationResponse{LastAppliedVersion: version}
|
||||
}
|
||||
|
||||
type mockRPCStream struct {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
type ConfigurationManager interface {
|
||||
UpdateConfiguration(ctx context.Context, version int32, config []byte) (*UpdateConfigurationResponse, error)
|
||||
UpdateConfiguration(ctx context.Context, version int32, config []byte) *UpdateConfigurationResponse
|
||||
}
|
||||
|
||||
type ConfigurationManager_PogsImpl struct {
|
||||
|
@ -31,16 +31,12 @@ func (i ConfigurationManager_PogsImpl) UpdateConfiguration(p tunnelrpc.Configura
|
|||
return err
|
||||
}
|
||||
|
||||
updateResp, err := i.impl.UpdateConfiguration(p.Ctx, version, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := p.Results.NewResult()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
updateResp := i.impl.UpdateConfiguration(p.Ctx, version, config)
|
||||
return updateResp.Marshal(result)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue