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
 | 
					// 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) {
 | 
					func (q *QUICConnection) UpdateConfiguration(ctx context.Context, version int32, config []byte) *tunnelpogs.UpdateConfigurationResponse {
 | 
				
			||||||
	return nil, fmt.Errorf("TODO: TUN-5698")
 | 
						return q.orchestrator.UpdateConfig(version, config)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// streamReadWriteAcker is a light wrapper over QUIC streams with a callback to send response back to
 | 
					// 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
 | 
						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 {
 | 
						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) {
 | 
						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 {
 | 
					type mockRPCStream struct {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ import (
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ConfigurationManager interface {
 | 
					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 {
 | 
					type ConfigurationManager_PogsImpl struct {
 | 
				
			||||||
| 
						 | 
					@ -31,16 +31,12 @@ func (i ConfigurationManager_PogsImpl) UpdateConfiguration(p tunnelrpc.Configura
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	updateResp, err := i.impl.UpdateConfiguration(p.Ctx, version, config)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	result, err := p.Results.NewResult()
 | 
						result, err := p.Results.NewResult()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						updateResp := i.impl.UpdateConfiguration(p.Ctx, version, config)
 | 
				
			||||||
	return updateResp.Marshal(result)
 | 
						return updateResp.Marshal(result)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue