auto-claude: subtask-1-2 - Create GrpcConfig class with development/production configs
Add GrpcConfig class following the pattern from ApiClientConfig with: - Development config: 192.168.88.228:5011 (plaintext/insecure) - Production config: grpc-route.goutezplanb.com:443 (TLS) - Host, port, timeout, useTls, and allowSelfSignedCertificate properties - Address getter for convenience Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4bd8ceab88
commit
74aef4ea06
59
lib/api/grpc_config.dart
Normal file
59
lib/api/grpc_config.dart
Normal file
@ -0,0 +1,59 @@
|
||||
/// Configuration for gRPC client connections.
|
||||
///
|
||||
/// Provides separate configurations for development and production environments
|
||||
/// with appropriate security settings for each.
|
||||
class GrpcConfig {
|
||||
/// The gRPC server host address.
|
||||
final String host;
|
||||
|
||||
/// The gRPC server port.
|
||||
final int port;
|
||||
|
||||
/// Connection timeout duration.
|
||||
final Duration timeout;
|
||||
|
||||
/// Whether to use TLS for secure connections.
|
||||
///
|
||||
/// When false, uses insecure (plaintext) credentials suitable only for
|
||||
/// development environments.
|
||||
final bool useTls;
|
||||
|
||||
/// Whether to allow self-signed certificates.
|
||||
///
|
||||
/// Only applicable when [useTls] is true. Useful for development
|
||||
/// environments with self-signed certificates.
|
||||
final bool allowSelfSignedCertificate;
|
||||
|
||||
const GrpcConfig({
|
||||
required this.host,
|
||||
required this.port,
|
||||
this.timeout = const Duration(seconds: 30),
|
||||
this.useTls = true,
|
||||
this.allowSelfSignedCertificate = false,
|
||||
});
|
||||
|
||||
/// Development configuration pointing to local/development gRPC server.
|
||||
///
|
||||
/// Uses plaintext (insecure) credentials for development convenience.
|
||||
static const GrpcConfig development = GrpcConfig(
|
||||
host: '192.168.88.228',
|
||||
port: 5011,
|
||||
timeout: Duration(seconds: 30),
|
||||
useTls: false,
|
||||
allowSelfSignedCertificate: true,
|
||||
);
|
||||
|
||||
/// Production configuration for the Plan B Logistics gRPC server.
|
||||
///
|
||||
/// Uses TLS for secure communication.
|
||||
static const GrpcConfig production = GrpcConfig(
|
||||
host: 'grpc-route.goutezplanb.com',
|
||||
port: 443,
|
||||
timeout: Duration(seconds: 30),
|
||||
useTls: true,
|
||||
allowSelfSignedCertificate: false,
|
||||
);
|
||||
|
||||
/// Returns the full address string in the format "host:port".
|
||||
String get address => '$host:$port';
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user