id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
connector-service_snippet_-2425448326891067086_25_50
clm
snippet
// connector-service/backend/grpc-server/src/error.rs Err(er.change_context(new_c)) } } } } /// Allow [error_stack::Report] to convert between error types /// This auto-implements [ReportSwitchExt] for the corresponding errors pub trait ErrorSwitch<T> { /// Get the next error type that the source error can be escalated into /// This does not consume the source error since we need to keep it in context fn switch(&self) -> T; } /// Allow [error_stack::Report] to convert between error types /// This serves as an alternative to [ErrorSwitch] pub trait ErrorSwitchFrom<T> { /// Convert to an error type that the source can be escalated into /// This does not consume the source error since we need to keep it in context fn switch_from(error: &T) -> Self; } impl<T, S> ErrorSwitch<T> for S where T: ErrorSwitchFrom<Self>, { fn switch(&self) -> T { T::switch_from(self) } } pub trait IntoGrpcStatus { fn into_grpc_status(self) -> Status; } pub trait ResultExtGrpc<T> { #[allow(clippy::result_large_err)] fn into_grpc_status(self) -> Result<T, Status>; } impl<T, E> ResultExtGrpc<T> for error_stack::Result<T, E> where error_stack::Report<E>: IntoGrpcStatus, { fn into_grpc_status(self) -> Result<T, Status> { match self { Ok(x) => Ok(x), Err(err) => Err(err.into_grpc_status()), } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_50_15
clm
snippet
// connector-service/backend/grpc-server/src/error.rs { fn switch(&self) -> T { T::switch_from(self) } } pub trait IntoGrpcStatus { fn into_grpc_status(self) -> Status; } pub trait ResultExtGrpc<T> { #[allow(clippy::result_large_err)] fn into_grpc_status(self) -> Result<T, Status>; } impl<T, E> ResultExtGrpc<T> for error_stack::Result<T, E>
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_50_30
clm
snippet
// connector-service/backend/grpc-server/src/error.rs { fn switch(&self) -> T { T::switch_from(self) } } pub trait IntoGrpcStatus { fn into_grpc_status(self) -> Status; } pub trait ResultExtGrpc<T> { #[allow(clippy::result_large_err)] fn into_grpc_status(self) -> Result<T, Status>; } impl<T, E> ResultExtGrpc<T> for error_stack::Result<T, E> where error_stack::Report<E>: IntoGrpcStatus, { fn into_grpc_status(self) -> Result<T, Status> { match self { Ok(x) => Ok(x), Err(err) => Err(err.into_grpc_status()), } } } #[derive(Debug, thiserror::Error)] pub enum ConfigurationError { #[error("Invalid host for socket: {0}")] AddressError(#[from] std::net::AddrParseError),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_50_50
clm
snippet
// connector-service/backend/grpc-server/src/error.rs { fn switch(&self) -> T { T::switch_from(self) } } pub trait IntoGrpcStatus { fn into_grpc_status(self) -> Status; } pub trait ResultExtGrpc<T> { #[allow(clippy::result_large_err)] fn into_grpc_status(self) -> Result<T, Status>; } impl<T, E> ResultExtGrpc<T> for error_stack::Result<T, E> where error_stack::Report<E>: IntoGrpcStatus, { fn into_grpc_status(self) -> Result<T, Status> { match self { Ok(x) => Ok(x), Err(err) => Err(err.into_grpc_status()), } } } #[derive(Debug, thiserror::Error)] pub enum ConfigurationError { #[error("Invalid host for socket: {0}")] AddressError(#[from] std::net::AddrParseError), #[error("Failed while building grpc reflection service: {0}")] GrpcReflectionServiceError(#[from] tonic_reflection::server::Error), #[error("Error while creating metrics server")] MetricsServerError, #[error("Error while creating the server: {0}")] ServerError(#[from] tonic::transport::Error), #[error("IO error: {0}")] IoError(#[from] std::io::Error), } impl ErrorSwitch<ApplicationErrorResponse> for ConnectorError { fn switch(&self) -> ApplicationErrorResponse { match self { Self::FailedToObtainIntegrationUrl | Self::FailedToObtainPreferredConnector | Self::FailedToObtainAuthType | Self::FailedToObtainCertificate | Self::FailedToObtainCertificateKey | Self::RequestEncodingFailed | Self::RequestEncodingFailedWithReason(_)
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_75_15
clm
snippet
// connector-service/backend/grpc-server/src/error.rs #[derive(Debug, thiserror::Error)] pub enum ConfigurationError { #[error("Invalid host for socket: {0}")] AddressError(#[from] std::net::AddrParseError), #[error("Failed while building grpc reflection service: {0}")] GrpcReflectionServiceError(#[from] tonic_reflection::server::Error), #[error("Error while creating metrics server")] MetricsServerError, #[error("Error while creating the server: {0}")] ServerError(#[from] tonic::transport::Error), #[error("IO error: {0}")] IoError(#[from] std::io::Error), }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_75_30
clm
snippet
// connector-service/backend/grpc-server/src/error.rs #[derive(Debug, thiserror::Error)] pub enum ConfigurationError { #[error("Invalid host for socket: {0}")] AddressError(#[from] std::net::AddrParseError), #[error("Failed while building grpc reflection service: {0}")] GrpcReflectionServiceError(#[from] tonic_reflection::server::Error), #[error("Error while creating metrics server")] MetricsServerError, #[error("Error while creating the server: {0}")] ServerError(#[from] tonic::transport::Error), #[error("IO error: {0}")] IoError(#[from] std::io::Error), } impl ErrorSwitch<ApplicationErrorResponse> for ConnectorError { fn switch(&self) -> ApplicationErrorResponse { match self { Self::FailedToObtainIntegrationUrl | Self::FailedToObtainPreferredConnector | Self::FailedToObtainAuthType | Self::FailedToObtainCertificate | Self::FailedToObtainCertificateKey | Self::RequestEncodingFailed | Self::RequestEncodingFailedWithReason(_) | Self::ParsingFailed | Self::ResponseDeserializationFailed | Self::ResponseHandlingFailed | Self::WebhookResponseEncodingFailed | Self::ProcessingStepFailed(_)
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_75_50
clm
snippet
// connector-service/backend/grpc-server/src/error.rs #[derive(Debug, thiserror::Error)] pub enum ConfigurationError { #[error("Invalid host for socket: {0}")] AddressError(#[from] std::net::AddrParseError), #[error("Failed while building grpc reflection service: {0}")] GrpcReflectionServiceError(#[from] tonic_reflection::server::Error), #[error("Error while creating metrics server")] MetricsServerError, #[error("Error while creating the server: {0}")] ServerError(#[from] tonic::transport::Error), #[error("IO error: {0}")] IoError(#[from] std::io::Error), } impl ErrorSwitch<ApplicationErrorResponse> for ConnectorError { fn switch(&self) -> ApplicationErrorResponse { match self { Self::FailedToObtainIntegrationUrl | Self::FailedToObtainPreferredConnector | Self::FailedToObtainAuthType | Self::FailedToObtainCertificate | Self::FailedToObtainCertificateKey | Self::RequestEncodingFailed | Self::RequestEncodingFailedWithReason(_) | Self::ParsingFailed | Self::ResponseDeserializationFailed | Self::ResponseHandlingFailed | Self::WebhookResponseEncodingFailed | Self::ProcessingStepFailed(_) | Self::UnexpectedResponseError(_) | Self::RoutingRulesParsingError | Self::FailedAtConnector { .. } | Self::AmountConversionFailed | Self::GenericError { .. } | Self::MandatePaymentDataMismatch { .. } => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(), error_object: None, }) } Self::InvalidConnectorName | Self::InvalidWallet | Self::MissingRequiredField { .. } | Self::MissingRequiredFields { .. } | Self::InvalidDateFormat | Self::NotSupported { .. } | Self::FlowNotSupported { .. }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_100_15
clm
snippet
// connector-service/backend/grpc-server/src/error.rs | Self::ParsingFailed | Self::ResponseDeserializationFailed | Self::ResponseHandlingFailed | Self::WebhookResponseEncodingFailed | Self::ProcessingStepFailed(_) | Self::UnexpectedResponseError(_) | Self::RoutingRulesParsingError | Self::FailedAtConnector { .. } | Self::AmountConversionFailed | Self::GenericError { .. } | Self::MandatePaymentDataMismatch { .. } => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_100_30
clm
snippet
// connector-service/backend/grpc-server/src/error.rs | Self::ParsingFailed | Self::ResponseDeserializationFailed | Self::ResponseHandlingFailed | Self::WebhookResponseEncodingFailed | Self::ProcessingStepFailed(_) | Self::UnexpectedResponseError(_) | Self::RoutingRulesParsingError | Self::FailedAtConnector { .. } | Self::AmountConversionFailed | Self::GenericError { .. } | Self::MandatePaymentDataMismatch { .. } => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(), error_object: None, }) } Self::InvalidConnectorName | Self::InvalidWallet | Self::MissingRequiredField { .. } | Self::MissingRequiredFields { .. } | Self::InvalidDateFormat | Self::NotSupported { .. } | Self::FlowNotSupported { .. } | Self::DateFormattingFailed | Self::InvalidDataFormat { .. } | Self::MismatchedPaymentData | Self::InvalidWalletToken { .. } | Self::FileValidationFailed { .. }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_100_50
clm
snippet
// connector-service/backend/grpc-server/src/error.rs | Self::ParsingFailed | Self::ResponseDeserializationFailed | Self::ResponseHandlingFailed | Self::WebhookResponseEncodingFailed | Self::ProcessingStepFailed(_) | Self::UnexpectedResponseError(_) | Self::RoutingRulesParsingError | Self::FailedAtConnector { .. } | Self::AmountConversionFailed | Self::GenericError { .. } | Self::MandatePaymentDataMismatch { .. } => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(), error_object: None, }) } Self::InvalidConnectorName | Self::InvalidWallet | Self::MissingRequiredField { .. } | Self::MissingRequiredFields { .. } | Self::InvalidDateFormat | Self::NotSupported { .. } | Self::FlowNotSupported { .. } | Self::DateFormattingFailed | Self::InvalidDataFormat { .. } | Self::MismatchedPaymentData | Self::InvalidWalletToken { .. } | Self::FileValidationFailed { .. } | Self::MissingConnectorRedirectionPayload { .. } | Self::MissingPaymentMethodType | Self::CurrencyNotSupported { .. } | Self::NoConnectorWalletDetails | Self::MissingConnectorMandateMetadata | Self::IntegrityCheckFailed { .. } | Self::SourceVerificationFailed | Self::InvalidConnectorConfig { .. } => { ApplicationErrorResponse::BadRequest(ApiError { sub_code: "BAD_REQUEST".to_string(), error_identifier: 400, error_message: self.to_string(), error_object: None, }) } Self::NoConnectorMetaData | Self::MissingConnectorMandateID | Self::MissingConnectorTransactionID | Self::MissingConnectorRefundID | Self::MissingConnectorRelatedTransactionID { .. }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_125_15
clm
snippet
// connector-service/backend/grpc-server/src/error.rs | Self::DateFormattingFailed | Self::InvalidDataFormat { .. } | Self::MismatchedPaymentData | Self::InvalidWalletToken { .. } | Self::FileValidationFailed { .. } | Self::MissingConnectorRedirectionPayload { .. } | Self::MissingPaymentMethodType | Self::CurrencyNotSupported { .. } | Self::NoConnectorWalletDetails | Self::MissingConnectorMandateMetadata | Self::IntegrityCheckFailed { .. } | Self::SourceVerificationFailed | Self::InvalidConnectorConfig { .. } => { ApplicationErrorResponse::BadRequest(ApiError { sub_code: "BAD_REQUEST".to_string(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_125_30
clm
snippet
// connector-service/backend/grpc-server/src/error.rs | Self::DateFormattingFailed | Self::InvalidDataFormat { .. } | Self::MismatchedPaymentData | Self::InvalidWalletToken { .. } | Self::FileValidationFailed { .. } | Self::MissingConnectorRedirectionPayload { .. } | Self::MissingPaymentMethodType | Self::CurrencyNotSupported { .. } | Self::NoConnectorWalletDetails | Self::MissingConnectorMandateMetadata | Self::IntegrityCheckFailed { .. } | Self::SourceVerificationFailed | Self::InvalidConnectorConfig { .. } => { ApplicationErrorResponse::BadRequest(ApiError { sub_code: "BAD_REQUEST".to_string(), error_identifier: 400, error_message: self.to_string(), error_object: None, }) } Self::NoConnectorMetaData | Self::MissingConnectorMandateID | Self::MissingConnectorTransactionID | Self::MissingConnectorRefundID | Self::MissingConnectorRelatedTransactionID { .. } | Self::InSufficientBalanceInPaymentMethod => { ApplicationErrorResponse::Unprocessable(ApiError { sub_code: "UNPROCESSABLE_ENTITY".to_string(), error_identifier: 422, error_message: self.to_string(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_125_50
clm
snippet
// connector-service/backend/grpc-server/src/error.rs | Self::DateFormattingFailed | Self::InvalidDataFormat { .. } | Self::MismatchedPaymentData | Self::InvalidWalletToken { .. } | Self::FileValidationFailed { .. } | Self::MissingConnectorRedirectionPayload { .. } | Self::MissingPaymentMethodType | Self::CurrencyNotSupported { .. } | Self::NoConnectorWalletDetails | Self::MissingConnectorMandateMetadata | Self::IntegrityCheckFailed { .. } | Self::SourceVerificationFailed | Self::InvalidConnectorConfig { .. } => { ApplicationErrorResponse::BadRequest(ApiError { sub_code: "BAD_REQUEST".to_string(), error_identifier: 400, error_message: self.to_string(), error_object: None, }) } Self::NoConnectorMetaData | Self::MissingConnectorMandateID | Self::MissingConnectorTransactionID | Self::MissingConnectorRefundID | Self::MissingConnectorRelatedTransactionID { .. } | Self::InSufficientBalanceInPaymentMethod => { ApplicationErrorResponse::Unprocessable(ApiError { sub_code: "UNPROCESSABLE_ENTITY".to_string(), error_identifier: 422, error_message: self.to_string(), error_object: None, }) } Self::NotImplemented(_) | Self::CaptureMethodNotSupported | Self::WebhooksNotImplemented => ApplicationErrorResponse::NotImplemented(ApiError { sub_code: "NOT_IMPLEMENTED".to_string(), error_identifier: 501, error_message: self.to_string(), error_object: None, }), Self::MissingApplePayTokenData | Self::WebhookBodyDecodingFailed | Self::WebhookSourceVerificationFailed | Self::WebhookVerificationSecretInvalid => { ApplicationErrorResponse::BadRequest(ApiError { sub_code: "INVALID_WEBHOOK_DATA".to_string(), error_identifier: 400, error_message: self.to_string(), error_object: None,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_150_15
clm
snippet
// connector-service/backend/grpc-server/src/error.rs | Self::InSufficientBalanceInPaymentMethod => { ApplicationErrorResponse::Unprocessable(ApiError { sub_code: "UNPROCESSABLE_ENTITY".to_string(), error_identifier: 422, error_message: self.to_string(), error_object: None, }) } Self::NotImplemented(_) | Self::CaptureMethodNotSupported | Self::WebhooksNotImplemented => ApplicationErrorResponse::NotImplemented(ApiError { sub_code: "NOT_IMPLEMENTED".to_string(), error_identifier: 501, error_message: self.to_string(), error_object: None,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_150_30
clm
snippet
// connector-service/backend/grpc-server/src/error.rs | Self::InSufficientBalanceInPaymentMethod => { ApplicationErrorResponse::Unprocessable(ApiError { sub_code: "UNPROCESSABLE_ENTITY".to_string(), error_identifier: 422, error_message: self.to_string(), error_object: None, }) } Self::NotImplemented(_) | Self::CaptureMethodNotSupported | Self::WebhooksNotImplemented => ApplicationErrorResponse::NotImplemented(ApiError { sub_code: "NOT_IMPLEMENTED".to_string(), error_identifier: 501, error_message: self.to_string(), error_object: None, }), Self::MissingApplePayTokenData | Self::WebhookBodyDecodingFailed | Self::WebhookSourceVerificationFailed | Self::WebhookVerificationSecretInvalid => { ApplicationErrorResponse::BadRequest(ApiError { sub_code: "INVALID_WEBHOOK_DATA".to_string(), error_identifier: 400, error_message: self.to_string(), error_object: None, }) } Self::RequestTimeoutReceived => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "REQUEST_TIMEOUT".to_string(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_150_50
clm
snippet
// connector-service/backend/grpc-server/src/error.rs | Self::InSufficientBalanceInPaymentMethod => { ApplicationErrorResponse::Unprocessable(ApiError { sub_code: "UNPROCESSABLE_ENTITY".to_string(), error_identifier: 422, error_message: self.to_string(), error_object: None, }) } Self::NotImplemented(_) | Self::CaptureMethodNotSupported | Self::WebhooksNotImplemented => ApplicationErrorResponse::NotImplemented(ApiError { sub_code: "NOT_IMPLEMENTED".to_string(), error_identifier: 501, error_message: self.to_string(), error_object: None, }), Self::MissingApplePayTokenData | Self::WebhookBodyDecodingFailed | Self::WebhookSourceVerificationFailed | Self::WebhookVerificationSecretInvalid => { ApplicationErrorResponse::BadRequest(ApiError { sub_code: "INVALID_WEBHOOK_DATA".to_string(), error_identifier: 400, error_message: self.to_string(), error_object: None, }) } Self::RequestTimeoutReceived => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "REQUEST_TIMEOUT".to_string(), error_identifier: 504, error_message: self.to_string(), error_object: None, }) } Self::WebhookEventTypeNotFound | Self::WebhookSignatureNotFound | Self::WebhookReferenceIdNotFound | Self::WebhookResourceObjectNotFound | Self::WebhookVerificationSecretNotFound => { ApplicationErrorResponse::NotFound(ApiError { sub_code: "WEBHOOK_DETAILS_NOT_FOUND".to_string(), error_identifier: 404, error_message: self.to_string(), error_object: None, }) } } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_175_15
clm
snippet
// connector-service/backend/grpc-server/src/error.rs }) } Self::RequestTimeoutReceived => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "REQUEST_TIMEOUT".to_string(), error_identifier: 504, error_message: self.to_string(), error_object: None, }) } Self::WebhookEventTypeNotFound | Self::WebhookSignatureNotFound | Self::WebhookReferenceIdNotFound | Self::WebhookResourceObjectNotFound | Self::WebhookVerificationSecretNotFound => {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_175_30
clm
snippet
// connector-service/backend/grpc-server/src/error.rs }) } Self::RequestTimeoutReceived => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "REQUEST_TIMEOUT".to_string(), error_identifier: 504, error_message: self.to_string(), error_object: None, }) } Self::WebhookEventTypeNotFound | Self::WebhookSignatureNotFound | Self::WebhookReferenceIdNotFound | Self::WebhookResourceObjectNotFound | Self::WebhookVerificationSecretNotFound => { ApplicationErrorResponse::NotFound(ApiError { sub_code: "WEBHOOK_DETAILS_NOT_FOUND".to_string(), error_identifier: 404, error_message: self.to_string(), error_object: None, }) } } } } impl ErrorSwitch<ApplicationErrorResponse> for ApiClientError { fn switch(&self) -> ApplicationErrorResponse { match self { Self::HeaderMapConstructionFailed
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_175_50
clm
snippet
// connector-service/backend/grpc-server/src/error.rs }) } Self::RequestTimeoutReceived => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "REQUEST_TIMEOUT".to_string(), error_identifier: 504, error_message: self.to_string(), error_object: None, }) } Self::WebhookEventTypeNotFound | Self::WebhookSignatureNotFound | Self::WebhookReferenceIdNotFound | Self::WebhookResourceObjectNotFound | Self::WebhookVerificationSecretNotFound => { ApplicationErrorResponse::NotFound(ApiError { sub_code: "WEBHOOK_DETAILS_NOT_FOUND".to_string(), error_identifier: 404, error_message: self.to_string(), error_object: None, }) } } } } impl ErrorSwitch<ApplicationErrorResponse> for ApiClientError { fn switch(&self) -> ApplicationErrorResponse { match self { Self::HeaderMapConstructionFailed | Self::InvalidProxyConfiguration | Self::ClientConstructionFailed | Self::CertificateDecodeFailed | Self::BodySerializationFailed | Self::UnexpectedState | Self::UrlEncodingFailed | Self::RequestNotSent(_) | Self::ResponseDecodingFailed | Self::InternalServerErrorReceived | Self::BadGatewayReceived | Self::ServiceUnavailableReceived | Self::UrlParsingFailed | Self::UnexpectedServerResponse => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(), error_object: None, }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_200_15
clm
snippet
// connector-service/backend/grpc-server/src/error.rs impl ErrorSwitch<ApplicationErrorResponse> for ApiClientError { fn switch(&self) -> ApplicationErrorResponse { match self { Self::HeaderMapConstructionFailed | Self::InvalidProxyConfiguration | Self::ClientConstructionFailed | Self::CertificateDecodeFailed | Self::BodySerializationFailed | Self::UnexpectedState | Self::UrlEncodingFailed | Self::RequestNotSent(_) | Self::ResponseDecodingFailed | Self::InternalServerErrorReceived | Self::BadGatewayReceived
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_200_30
clm
snippet
// connector-service/backend/grpc-server/src/error.rs impl ErrorSwitch<ApplicationErrorResponse> for ApiClientError { fn switch(&self) -> ApplicationErrorResponse { match self { Self::HeaderMapConstructionFailed | Self::InvalidProxyConfiguration | Self::ClientConstructionFailed | Self::CertificateDecodeFailed | Self::BodySerializationFailed | Self::UnexpectedState | Self::UrlEncodingFailed | Self::RequestNotSent(_) | Self::ResponseDecodingFailed | Self::InternalServerErrorReceived | Self::BadGatewayReceived | Self::ServiceUnavailableReceived | Self::UrlParsingFailed | Self::UnexpectedServerResponse => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(), error_object: None, }) } Self::RequestTimeoutReceived | Self::GatewayTimeoutReceived => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "REQUEST_TIMEOUT".to_string(), error_identifier: 504, error_message: self.to_string(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_200_50
clm
snippet
// connector-service/backend/grpc-server/src/error.rs impl ErrorSwitch<ApplicationErrorResponse> for ApiClientError { fn switch(&self) -> ApplicationErrorResponse { match self { Self::HeaderMapConstructionFailed | Self::InvalidProxyConfiguration | Self::ClientConstructionFailed | Self::CertificateDecodeFailed | Self::BodySerializationFailed | Self::UnexpectedState | Self::UrlEncodingFailed | Self::RequestNotSent(_) | Self::ResponseDecodingFailed | Self::InternalServerErrorReceived | Self::BadGatewayReceived | Self::ServiceUnavailableReceived | Self::UrlParsingFailed | Self::UnexpectedServerResponse => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(), error_object: None, }) } Self::RequestTimeoutReceived | Self::GatewayTimeoutReceived => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "REQUEST_TIMEOUT".to_string(), error_identifier: 504, error_message: self.to_string(), error_object: None, }) } Self::ConnectionClosedIncompleteMessage => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(), error_object: None, }) } } } } impl IntoGrpcStatus for error_stack::Report<ApplicationErrorResponse> { fn into_grpc_status(self) -> Status { logger::error!(error=?self); match self.current_context() { ApplicationErrorResponse::Unauthorized(api_error) => {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_225_15
clm
snippet
// connector-service/backend/grpc-server/src/error.rs Self::RequestTimeoutReceived | Self::GatewayTimeoutReceived => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "REQUEST_TIMEOUT".to_string(), error_identifier: 504, error_message: self.to_string(), error_object: None, }) } Self::ConnectionClosedIncompleteMessage => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(), error_object: None, })
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_225_30
clm
snippet
// connector-service/backend/grpc-server/src/error.rs Self::RequestTimeoutReceived | Self::GatewayTimeoutReceived => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "REQUEST_TIMEOUT".to_string(), error_identifier: 504, error_message: self.to_string(), error_object: None, }) } Self::ConnectionClosedIncompleteMessage => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(), error_object: None, }) } } } } impl IntoGrpcStatus for error_stack::Report<ApplicationErrorResponse> { fn into_grpc_status(self) -> Status { logger::error!(error=?self); match self.current_context() { ApplicationErrorResponse::Unauthorized(api_error) => { Status::unauthenticated(&api_error.error_message) } ApplicationErrorResponse::ForbiddenCommonResource(api_error) | ApplicationErrorResponse::ForbiddenPrivateResource(api_error) => { Status::permission_denied(&api_error.error_message)
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_225_50
clm
snippet
// connector-service/backend/grpc-server/src/error.rs Self::RequestTimeoutReceived | Self::GatewayTimeoutReceived => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "REQUEST_TIMEOUT".to_string(), error_identifier: 504, error_message: self.to_string(), error_object: None, }) } Self::ConnectionClosedIncompleteMessage => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(), error_object: None, }) } } } } impl IntoGrpcStatus for error_stack::Report<ApplicationErrorResponse> { fn into_grpc_status(self) -> Status { logger::error!(error=?self); match self.current_context() { ApplicationErrorResponse::Unauthorized(api_error) => { Status::unauthenticated(&api_error.error_message) } ApplicationErrorResponse::ForbiddenCommonResource(api_error) | ApplicationErrorResponse::ForbiddenPrivateResource(api_error) => { Status::permission_denied(&api_error.error_message) } ApplicationErrorResponse::Conflict(api_error) | ApplicationErrorResponse::Gone(api_error) | ApplicationErrorResponse::Unprocessable(api_error) | ApplicationErrorResponse::InternalServerError(api_error) | ApplicationErrorResponse::MethodNotAllowed(api_error) | ApplicationErrorResponse::DomainError(api_error) => { Status::internal(&api_error.error_message) } ApplicationErrorResponse::NotImplemented(api_error) => { Status::unimplemented(&api_error.error_message) } ApplicationErrorResponse::NotFound(api_error) => { Status::not_found(&api_error.error_message) } ApplicationErrorResponse::BadRequest(api_error) => { Status::invalid_argument(&api_error.error_message) } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_250_15
clm
snippet
// connector-service/backend/grpc-server/src/error.rs Status::unauthenticated(&api_error.error_message) } ApplicationErrorResponse::ForbiddenCommonResource(api_error) | ApplicationErrorResponse::ForbiddenPrivateResource(api_error) => { Status::permission_denied(&api_error.error_message) } ApplicationErrorResponse::Conflict(api_error) | ApplicationErrorResponse::Gone(api_error) | ApplicationErrorResponse::Unprocessable(api_error) | ApplicationErrorResponse::InternalServerError(api_error) | ApplicationErrorResponse::MethodNotAllowed(api_error) | ApplicationErrorResponse::DomainError(api_error) => { Status::internal(&api_error.error_message) } ApplicationErrorResponse::NotImplemented(api_error) => {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 250, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_250_30
clm
snippet
// connector-service/backend/grpc-server/src/error.rs Status::unauthenticated(&api_error.error_message) } ApplicationErrorResponse::ForbiddenCommonResource(api_error) | ApplicationErrorResponse::ForbiddenPrivateResource(api_error) => { Status::permission_denied(&api_error.error_message) } ApplicationErrorResponse::Conflict(api_error) | ApplicationErrorResponse::Gone(api_error) | ApplicationErrorResponse::Unprocessable(api_error) | ApplicationErrorResponse::InternalServerError(api_error) | ApplicationErrorResponse::MethodNotAllowed(api_error) | ApplicationErrorResponse::DomainError(api_error) => { Status::internal(&api_error.error_message) } ApplicationErrorResponse::NotImplemented(api_error) => { Status::unimplemented(&api_error.error_message) } ApplicationErrorResponse::NotFound(api_error) => { Status::not_found(&api_error.error_message) } ApplicationErrorResponse::BadRequest(api_error) => { Status::invalid_argument(&api_error.error_message) } } } } #[derive(Debug, Clone)] pub struct PaymentAuthorizationError { pub status: grpc_api_types::payments::PaymentStatus,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 250, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_250_50
clm
snippet
// connector-service/backend/grpc-server/src/error.rs Status::unauthenticated(&api_error.error_message) } ApplicationErrorResponse::ForbiddenCommonResource(api_error) | ApplicationErrorResponse::ForbiddenPrivateResource(api_error) => { Status::permission_denied(&api_error.error_message) } ApplicationErrorResponse::Conflict(api_error) | ApplicationErrorResponse::Gone(api_error) | ApplicationErrorResponse::Unprocessable(api_error) | ApplicationErrorResponse::InternalServerError(api_error) | ApplicationErrorResponse::MethodNotAllowed(api_error) | ApplicationErrorResponse::DomainError(api_error) => { Status::internal(&api_error.error_message) } ApplicationErrorResponse::NotImplemented(api_error) => { Status::unimplemented(&api_error.error_message) } ApplicationErrorResponse::NotFound(api_error) => { Status::not_found(&api_error.error_message) } ApplicationErrorResponse::BadRequest(api_error) => { Status::invalid_argument(&api_error.error_message) } } } } #[derive(Debug, Clone)] pub struct PaymentAuthorizationError { pub status: grpc_api_types::payments::PaymentStatus, pub error_message: Option<String>, pub error_code: Option<String>, pub status_code: Option<u32>, } impl PaymentAuthorizationError { pub fn new( status: grpc_api_types::payments::PaymentStatus, error_message: Option<String>, error_code: Option<String>, status_code: Option<u32>, ) -> Self { Self { status, error_message, error_code, status_code, } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 250, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_275_15
clm
snippet
// connector-service/backend/grpc-server/src/error.rs } #[derive(Debug, Clone)] pub struct PaymentAuthorizationError { pub status: grpc_api_types::payments::PaymentStatus, pub error_message: Option<String>, pub error_code: Option<String>, pub status_code: Option<u32>, } impl PaymentAuthorizationError { pub fn new( status: grpc_api_types::payments::PaymentStatus, error_message: Option<String>, error_code: Option<String>,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 275, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_275_30
clm
snippet
// connector-service/backend/grpc-server/src/error.rs } #[derive(Debug, Clone)] pub struct PaymentAuthorizationError { pub status: grpc_api_types::payments::PaymentStatus, pub error_message: Option<String>, pub error_code: Option<String>, pub status_code: Option<u32>, } impl PaymentAuthorizationError { pub fn new( status: grpc_api_types::payments::PaymentStatus, error_message: Option<String>, error_code: Option<String>, status_code: Option<u32>, ) -> Self { Self { status, error_message, error_code, status_code, } } } impl From<PaymentAuthorizationError> for PaymentServiceAuthorizeResponse { fn from(error: PaymentAuthorizationError) -> Self { Self { transaction_id: None,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 275, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_275_50
clm
snippet
// connector-service/backend/grpc-server/src/error.rs } #[derive(Debug, Clone)] pub struct PaymentAuthorizationError { pub status: grpc_api_types::payments::PaymentStatus, pub error_message: Option<String>, pub error_code: Option<String>, pub status_code: Option<u32>, } impl PaymentAuthorizationError { pub fn new( status: grpc_api_types::payments::PaymentStatus, error_message: Option<String>, error_code: Option<String>, status_code: Option<u32>, ) -> Self { Self { status, error_message, error_code, status_code, } } } impl From<PaymentAuthorizationError> for PaymentServiceAuthorizeResponse { fn from(error: PaymentAuthorizationError) -> Self { Self { transaction_id: None, redirection_data: None, network_txn_id: None, response_ref_id: None, incremental_authorization_allowed: None, status: error.status.into(), error_message: error.error_message, error_code: error.error_code, status_code: error.status_code.unwrap_or(500), response_headers: std::collections::HashMap::new(), connector_metadata: std::collections::HashMap::new(), raw_connector_response: None, raw_connector_request: None, state: None, mandate_reference: None, minor_amount_capturable: None, minor_captured_amount: None, captured_amount: None, connector_response: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 275, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_300_15
clm
snippet
// connector-service/backend/grpc-server/src/error.rs impl From<PaymentAuthorizationError> for PaymentServiceAuthorizeResponse { fn from(error: PaymentAuthorizationError) -> Self { Self { transaction_id: None, redirection_data: None, network_txn_id: None, response_ref_id: None, incremental_authorization_allowed: None, status: error.status.into(), error_message: error.error_message, error_code: error.error_code, status_code: error.status_code.unwrap_or(500), response_headers: std::collections::HashMap::new(), connector_metadata: std::collections::HashMap::new(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 300, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_300_30
clm
snippet
// connector-service/backend/grpc-server/src/error.rs impl From<PaymentAuthorizationError> for PaymentServiceAuthorizeResponse { fn from(error: PaymentAuthorizationError) -> Self { Self { transaction_id: None, redirection_data: None, network_txn_id: None, response_ref_id: None, incremental_authorization_allowed: None, status: error.status.into(), error_message: error.error_message, error_code: error.error_code, status_code: error.status_code.unwrap_or(500), response_headers: std::collections::HashMap::new(), connector_metadata: std::collections::HashMap::new(), raw_connector_response: None, raw_connector_request: None, state: None, mandate_reference: None, minor_amount_capturable: None, minor_captured_amount: None, captured_amount: None, connector_response: None, } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 26, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 300, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2425448326891067086_300_50
clm
snippet
// connector-service/backend/grpc-server/src/error.rs impl From<PaymentAuthorizationError> for PaymentServiceAuthorizeResponse { fn from(error: PaymentAuthorizationError) -> Self { Self { transaction_id: None, redirection_data: None, network_txn_id: None, response_ref_id: None, incremental_authorization_allowed: None, status: error.status.into(), error_message: error.error_message, error_code: error.error_code, status_code: error.status_code.unwrap_or(500), response_headers: std::collections::HashMap::new(), connector_metadata: std::collections::HashMap::new(), raw_connector_response: None, raw_connector_request: None, state: None, mandate_reference: None, minor_amount_capturable: None, minor_captured_amount: None, captured_amount: None, connector_response: None, } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 26, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 300, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_0_15
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs use std::path::PathBuf; use common_utils::{consts, events::EventConfig, metadata::HeaderMaskingConfig}; use domain_types::types::{Connectors, Proxy}; use crate::{error::ConfigurationError, logger::config::Log}; #[derive(Clone, serde::Deserialize, Debug)] pub struct Config { pub common: Common, pub server: Server, pub metrics: MetricsServer, pub log: Log, pub proxy: Proxy, pub connectors: Connectors,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_0_30
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs use std::path::PathBuf; use common_utils::{consts, events::EventConfig, metadata::HeaderMaskingConfig}; use domain_types::types::{Connectors, Proxy}; use crate::{error::ConfigurationError, logger::config::Log}; #[derive(Clone, serde::Deserialize, Debug)] pub struct Config { pub common: Common, pub server: Server, pub metrics: MetricsServer, pub log: Log, pub proxy: Proxy, pub connectors: Connectors, #[serde(default)] pub events: EventConfig, #[serde(default)] pub lineage: LineageConfig, #[serde(default)] pub unmasked_headers: HeaderMaskingConfig, } #[derive(Clone, serde::Deserialize, Debug, Default)] pub struct LineageConfig { /// Enable processing of x-lineage-ids header pub enabled: bool, /// Custom header name (default: x-lineage-ids) #[serde(default = "default_lineage_header")] pub header_name: String,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_0_50
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs use std::path::PathBuf; use common_utils::{consts, events::EventConfig, metadata::HeaderMaskingConfig}; use domain_types::types::{Connectors, Proxy}; use crate::{error::ConfigurationError, logger::config::Log}; #[derive(Clone, serde::Deserialize, Debug)] pub struct Config { pub common: Common, pub server: Server, pub metrics: MetricsServer, pub log: Log, pub proxy: Proxy, pub connectors: Connectors, #[serde(default)] pub events: EventConfig, #[serde(default)] pub lineage: LineageConfig, #[serde(default)] pub unmasked_headers: HeaderMaskingConfig, } #[derive(Clone, serde::Deserialize, Debug, Default)] pub struct LineageConfig { /// Enable processing of x-lineage-ids header pub enabled: bool, /// Custom header name (default: x-lineage-ids) #[serde(default = "default_lineage_header")] pub header_name: String, /// Prefix for lineage fields in events #[serde(default = "default_lineage_prefix")] pub field_prefix: String, } fn default_lineage_header() -> String { consts::X_LINEAGE_IDS.to_string() } fn default_lineage_prefix() -> String { consts::LINEAGE_FIELD_PREFIX.to_string() } #[derive(Clone, serde::Deserialize, Debug)] pub struct Common { pub environment: consts::Env, } impl Common { pub fn validate(&self) -> Result<(), config::ConfigError> {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_25_15
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs /// Enable processing of x-lineage-ids header pub enabled: bool, /// Custom header name (default: x-lineage-ids) #[serde(default = "default_lineage_header")] pub header_name: String, /// Prefix for lineage fields in events #[serde(default = "default_lineage_prefix")] pub field_prefix: String, } fn default_lineage_header() -> String { consts::X_LINEAGE_IDS.to_string() } fn default_lineage_prefix() -> String {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_25_30
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs /// Enable processing of x-lineage-ids header pub enabled: bool, /// Custom header name (default: x-lineage-ids) #[serde(default = "default_lineage_header")] pub header_name: String, /// Prefix for lineage fields in events #[serde(default = "default_lineage_prefix")] pub field_prefix: String, } fn default_lineage_header() -> String { consts::X_LINEAGE_IDS.to_string() } fn default_lineage_prefix() -> String { consts::LINEAGE_FIELD_PREFIX.to_string() } #[derive(Clone, serde::Deserialize, Debug)] pub struct Common { pub environment: consts::Env, } impl Common { pub fn validate(&self) -> Result<(), config::ConfigError> { let Self { environment } = self; match environment { consts::Env::Development | consts::Env::Production | consts::Env::Sandbox => Ok(()), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_25_50
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs /// Enable processing of x-lineage-ids header pub enabled: bool, /// Custom header name (default: x-lineage-ids) #[serde(default = "default_lineage_header")] pub header_name: String, /// Prefix for lineage fields in events #[serde(default = "default_lineage_prefix")] pub field_prefix: String, } fn default_lineage_header() -> String { consts::X_LINEAGE_IDS.to_string() } fn default_lineage_prefix() -> String { consts::LINEAGE_FIELD_PREFIX.to_string() } #[derive(Clone, serde::Deserialize, Debug)] pub struct Common { pub environment: consts::Env, } impl Common { pub fn validate(&self) -> Result<(), config::ConfigError> { let Self { environment } = self; match environment { consts::Env::Development | consts::Env::Production | consts::Env::Sandbox => Ok(()), } } } #[derive(Clone, serde::Deserialize, Debug)] pub struct Server { pub host: String, pub port: u16, #[serde(rename = "type", default)] pub type_: ServiceType, } #[derive(Clone, serde::Deserialize, Debug)] pub struct MetricsServer { pub host: String, pub port: u16, } #[derive(Clone, serde::Deserialize, Debug, Default)] #[serde(rename_all = "snake_case")] pub enum ServiceType { #[default]
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_50_15
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs let Self { environment } = self; match environment { consts::Env::Development | consts::Env::Production | consts::Env::Sandbox => Ok(()), } } } #[derive(Clone, serde::Deserialize, Debug)] pub struct Server { pub host: String, pub port: u16, #[serde(rename = "type", default)] pub type_: ServiceType, }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_50_30
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs let Self { environment } = self; match environment { consts::Env::Development | consts::Env::Production | consts::Env::Sandbox => Ok(()), } } } #[derive(Clone, serde::Deserialize, Debug)] pub struct Server { pub host: String, pub port: u16, #[serde(rename = "type", default)] pub type_: ServiceType, } #[derive(Clone, serde::Deserialize, Debug)] pub struct MetricsServer { pub host: String, pub port: u16, } #[derive(Clone, serde::Deserialize, Debug, Default)] #[serde(rename_all = "snake_case")] pub enum ServiceType { #[default] Grpc, Http, } impl Config {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_50_50
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs let Self { environment } = self; match environment { consts::Env::Development | consts::Env::Production | consts::Env::Sandbox => Ok(()), } } } #[derive(Clone, serde::Deserialize, Debug)] pub struct Server { pub host: String, pub port: u16, #[serde(rename = "type", default)] pub type_: ServiceType, } #[derive(Clone, serde::Deserialize, Debug)] pub struct MetricsServer { pub host: String, pub port: u16, } #[derive(Clone, serde::Deserialize, Debug, Default)] #[serde(rename_all = "snake_case")] pub enum ServiceType { #[default] Grpc, Http, } impl Config { /// Function to build the configuration by picking it from default locations pub fn new() -> Result<Self, config::ConfigError> { Self::new_with_config_path(None) } /// Function to build the configuration by picking it from default locations pub fn new_with_config_path( explicit_config_path: Option<PathBuf>, ) -> Result<Self, config::ConfigError> { let env = consts::Env::current_env(); let config_path = Self::config_path(&env, explicit_config_path); let config = Self::builder(&env)? .add_source(config::File::from(config_path).required(false)) .add_source( config::Environment::with_prefix(consts::ENV_PREFIX) .try_parsing(true) .separator("__") .list_separator(",") .with_list_parse_key("proxy.bypass_proxy_urls")
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_75_15
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs Grpc, Http, } impl Config { /// Function to build the configuration by picking it from default locations pub fn new() -> Result<Self, config::ConfigError> { Self::new_with_config_path(None) } /// Function to build the configuration by picking it from default locations pub fn new_with_config_path( explicit_config_path: Option<PathBuf>, ) -> Result<Self, config::ConfigError> { let env = consts::Env::current_env();
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_75_30
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs Grpc, Http, } impl Config { /// Function to build the configuration by picking it from default locations pub fn new() -> Result<Self, config::ConfigError> { Self::new_with_config_path(None) } /// Function to build the configuration by picking it from default locations pub fn new_with_config_path( explicit_config_path: Option<PathBuf>, ) -> Result<Self, config::ConfigError> { let env = consts::Env::current_env(); let config_path = Self::config_path(&env, explicit_config_path); let config = Self::builder(&env)? .add_source(config::File::from(config_path).required(false)) .add_source( config::Environment::with_prefix(consts::ENV_PREFIX) .try_parsing(true) .separator("__") .list_separator(",") .with_list_parse_key("proxy.bypass_proxy_urls") .with_list_parse_key("redis.cluster_urls") .with_list_parse_key("database.tenants") .with_list_parse_key("log.kafka.brokers") .with_list_parse_key("events.brokers") .with_list_parse_key("unmasked_headers.keys"),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_75_50
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs Grpc, Http, } impl Config { /// Function to build the configuration by picking it from default locations pub fn new() -> Result<Self, config::ConfigError> { Self::new_with_config_path(None) } /// Function to build the configuration by picking it from default locations pub fn new_with_config_path( explicit_config_path: Option<PathBuf>, ) -> Result<Self, config::ConfigError> { let env = consts::Env::current_env(); let config_path = Self::config_path(&env, explicit_config_path); let config = Self::builder(&env)? .add_source(config::File::from(config_path).required(false)) .add_source( config::Environment::with_prefix(consts::ENV_PREFIX) .try_parsing(true) .separator("__") .list_separator(",") .with_list_parse_key("proxy.bypass_proxy_urls") .with_list_parse_key("redis.cluster_urls") .with_list_parse_key("database.tenants") .with_list_parse_key("log.kafka.brokers") .with_list_parse_key("events.brokers") .with_list_parse_key("unmasked_headers.keys"), ) .build()?; #[allow(clippy::print_stderr)] let config: Self = serde_path_to_error::deserialize(config).map_err(|error| { eprintln!("Unable to deserialize application configuration: {error}"); error.into_inner() })?; // Validate the environment field config.common.validate()?; Ok(config) } pub fn builder( environment: &consts::Env, ) -> Result<config::ConfigBuilder<config::builder::DefaultState>, config::ConfigError> { config::Config::builder() // Here, it should be `set_override()` not `set_default()`.
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_100_15
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs .with_list_parse_key("redis.cluster_urls") .with_list_parse_key("database.tenants") .with_list_parse_key("log.kafka.brokers") .with_list_parse_key("events.brokers") .with_list_parse_key("unmasked_headers.keys"), ) .build()?; #[allow(clippy::print_stderr)] let config: Self = serde_path_to_error::deserialize(config).map_err(|error| { eprintln!("Unable to deserialize application configuration: {error}"); error.into_inner() })?; // Validate the environment field
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_100_30
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs .with_list_parse_key("redis.cluster_urls") .with_list_parse_key("database.tenants") .with_list_parse_key("log.kafka.brokers") .with_list_parse_key("events.brokers") .with_list_parse_key("unmasked_headers.keys"), ) .build()?; #[allow(clippy::print_stderr)] let config: Self = serde_path_to_error::deserialize(config).map_err(|error| { eprintln!("Unable to deserialize application configuration: {error}"); error.into_inner() })?; // Validate the environment field config.common.validate()?; Ok(config) } pub fn builder( environment: &consts::Env, ) -> Result<config::ConfigBuilder<config::builder::DefaultState>, config::ConfigError> { config::Config::builder() // Here, it should be `set_override()` not `set_default()`. // "env" can't be altered by config field. // Should be single source of truth. .set_override("env", environment.to_string()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_100_50
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs .with_list_parse_key("redis.cluster_urls") .with_list_parse_key("database.tenants") .with_list_parse_key("log.kafka.brokers") .with_list_parse_key("events.brokers") .with_list_parse_key("unmasked_headers.keys"), ) .build()?; #[allow(clippy::print_stderr)] let config: Self = serde_path_to_error::deserialize(config).map_err(|error| { eprintln!("Unable to deserialize application configuration: {error}"); error.into_inner() })?; // Validate the environment field config.common.validate()?; Ok(config) } pub fn builder( environment: &consts::Env, ) -> Result<config::ConfigBuilder<config::builder::DefaultState>, config::ConfigError> { config::Config::builder() // Here, it should be `set_override()` not `set_default()`. // "env" can't be altered by config field. // Should be single source of truth. .set_override("env", environment.to_string()) } /// Config path. pub fn config_path( environment: &consts::Env, explicit_config_path: Option<PathBuf>, ) -> PathBuf { let mut config_path = PathBuf::new(); if let Some(explicit_config_path_val) = explicit_config_path { config_path.push(explicit_config_path_val); } else { let config_directory: String = "config".into(); let config_file_name = environment.config_path(); config_path.push(workspace_path()); config_path.push(config_directory); config_path.push(config_file_name); } config_path } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_125_15
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs // "env" can't be altered by config field. // Should be single source of truth. .set_override("env", environment.to_string()) } /// Config path. pub fn config_path( environment: &consts::Env, explicit_config_path: Option<PathBuf>, ) -> PathBuf { let mut config_path = PathBuf::new(); if let Some(explicit_config_path_val) = explicit_config_path { config_path.push(explicit_config_path_val); } else { let config_directory: String = "config".into();
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_125_30
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs // "env" can't be altered by config field. // Should be single source of truth. .set_override("env", environment.to_string()) } /// Config path. pub fn config_path( environment: &consts::Env, explicit_config_path: Option<PathBuf>, ) -> PathBuf { let mut config_path = PathBuf::new(); if let Some(explicit_config_path_val) = explicit_config_path { config_path.push(explicit_config_path_val); } else { let config_directory: String = "config".into(); let config_file_name = environment.config_path(); config_path.push(workspace_path()); config_path.push(config_directory); config_path.push(config_file_name); } config_path } } impl Server { pub async fn tcp_listener(&self) -> Result<tokio::net::TcpListener, ConfigurationError> { let loc = format!("{}:{}", self.host, self.port); tracing::info!(loc = %loc, "binding the server");
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_125_50
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs // "env" can't be altered by config field. // Should be single source of truth. .set_override("env", environment.to_string()) } /// Config path. pub fn config_path( environment: &consts::Env, explicit_config_path: Option<PathBuf>, ) -> PathBuf { let mut config_path = PathBuf::new(); if let Some(explicit_config_path_val) = explicit_config_path { config_path.push(explicit_config_path_val); } else { let config_directory: String = "config".into(); let config_file_name = environment.config_path(); config_path.push(workspace_path()); config_path.push(config_directory); config_path.push(config_file_name); } config_path } } impl Server { pub async fn tcp_listener(&self) -> Result<tokio::net::TcpListener, ConfigurationError> { let loc = format!("{}:{}", self.host, self.port); tracing::info!(loc = %loc, "binding the server"); Ok(tokio::net::TcpListener::bind(loc).await?) } } impl MetricsServer { pub async fn tcp_listener(&self) -> Result<tokio::net::TcpListener, ConfigurationError> { let loc = format!("{}:{}", self.host, self.port); tracing::info!(loc = %loc, "binding the server"); Ok(tokio::net::TcpListener::bind(loc).await?) } } pub fn workspace_path() -> PathBuf { if let Ok(manifest_dir) = std::env::var("CARGO_MANIFEST_DIR") { let mut path = PathBuf::from(manifest_dir); path.pop(); path.pop();
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_150_15
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs impl Server { pub async fn tcp_listener(&self) -> Result<tokio::net::TcpListener, ConfigurationError> { let loc = format!("{}:{}", self.host, self.port); tracing::info!(loc = %loc, "binding the server"); Ok(tokio::net::TcpListener::bind(loc).await?) } } impl MetricsServer { pub async fn tcp_listener(&self) -> Result<tokio::net::TcpListener, ConfigurationError> { let loc = format!("{}:{}", self.host, self.port); tracing::info!(loc = %loc, "binding the server");
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_150_30
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs impl Server { pub async fn tcp_listener(&self) -> Result<tokio::net::TcpListener, ConfigurationError> { let loc = format!("{}:{}", self.host, self.port); tracing::info!(loc = %loc, "binding the server"); Ok(tokio::net::TcpListener::bind(loc).await?) } } impl MetricsServer { pub async fn tcp_listener(&self) -> Result<tokio::net::TcpListener, ConfigurationError> { let loc = format!("{}:{}", self.host, self.port); tracing::info!(loc = %loc, "binding the server"); Ok(tokio::net::TcpListener::bind(loc).await?) } } pub fn workspace_path() -> PathBuf { if let Ok(manifest_dir) = std::env::var("CARGO_MANIFEST_DIR") { let mut path = PathBuf::from(manifest_dir); path.pop(); path.pop(); path } else { PathBuf::from(".") } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8674746398584233230_150_50
clm
snippet
// connector-service/backend/grpc-server/src/configs.rs impl Server { pub async fn tcp_listener(&self) -> Result<tokio::net::TcpListener, ConfigurationError> { let loc = format!("{}:{}", self.host, self.port); tracing::info!(loc = %loc, "binding the server"); Ok(tokio::net::TcpListener::bind(loc).await?) } } impl MetricsServer { pub async fn tcp_listener(&self) -> Result<tokio::net::TcpListener, ConfigurationError> { let loc = format!("{}:{}", self.host, self.port); tracing::info!(loc = %loc, "binding the server"); Ok(tokio::net::TcpListener::bind(loc).await?) } } pub fn workspace_path() -> PathBuf { if let Ok(manifest_dir) = std::env::var("CARGO_MANIFEST_DIR") { let mut path = PathBuf::from(manifest_dir); path.pop(); path.pop(); path } else { PathBuf::from(".") } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1708118210077285516_0_15
clm
snippet
// connector-service/backend/grpc-server/src/main.rs use grpc_server::{self, app, configs, logger}; #[allow(clippy::unwrap_in_result)] #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { #[cfg(debug_assertions)] verify_other_config_files(); #[allow(clippy::expect_used)] let config = configs::Config::new().expect("Failed while parsing config"); let _guard = logger::setup( &config.log, grpc_server::service_name!(), [grpc_server::service_name!(), "grpc_server", "tower_http"], );
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1708118210077285516_0_30
clm
snippet
// connector-service/backend/grpc-server/src/main.rs use grpc_server::{self, app, configs, logger}; #[allow(clippy::unwrap_in_result)] #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { #[cfg(debug_assertions)] verify_other_config_files(); #[allow(clippy::expect_used)] let config = configs::Config::new().expect("Failed while parsing config"); let _guard = logger::setup( &config.log, grpc_server::service_name!(), [grpc_server::service_name!(), "grpc_server", "tower_http"], ); let metrics_server = app::metrics_server_builder(config.clone()); let server = app::server_builder(config); #[allow(clippy::expect_used)] tokio::try_join!(metrics_server, server)?; Ok(()) } #[cfg(debug_assertions)] fn verify_other_config_files() { use std::path::PathBuf; use crate::configs; let config_file_names = vec!["production.toml", "sandbox.toml"];
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1708118210077285516_0_50
clm
snippet
// connector-service/backend/grpc-server/src/main.rs use grpc_server::{self, app, configs, logger}; #[allow(clippy::unwrap_in_result)] #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { #[cfg(debug_assertions)] verify_other_config_files(); #[allow(clippy::expect_used)] let config = configs::Config::new().expect("Failed while parsing config"); let _guard = logger::setup( &config.log, grpc_server::service_name!(), [grpc_server::service_name!(), "grpc_server", "tower_http"], ); let metrics_server = app::metrics_server_builder(config.clone()); let server = app::server_builder(config); #[allow(clippy::expect_used)] tokio::try_join!(metrics_server, server)?; Ok(()) } #[cfg(debug_assertions)] fn verify_other_config_files() { use std::path::PathBuf; use crate::configs; let config_file_names = vec!["production.toml", "sandbox.toml"]; let mut config_path = PathBuf::new(); config_path.push(configs::workspace_path()); let config_directory: String = "config".into(); config_path.push(config_directory); for config_file_name in config_file_names { config_path.push(config_file_name); #[allow(clippy::panic)] let _ = configs::Config::new_with_config_path(Some(config_path.clone())) .unwrap_or_else(|_| panic!("Update {config_file_name} with the default config values")); config_path.pop(); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 42, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1708118210077285516_25_15
clm
snippet
// connector-service/backend/grpc-server/src/main.rs fn verify_other_config_files() { use std::path::PathBuf; use crate::configs; let config_file_names = vec!["production.toml", "sandbox.toml"]; let mut config_path = PathBuf::new(); config_path.push(configs::workspace_path()); let config_directory: String = "config".into(); config_path.push(config_directory); for config_file_name in config_file_names { config_path.push(config_file_name); #[allow(clippy::panic)] let _ = configs::Config::new_with_config_path(Some(config_path.clone())) .unwrap_or_else(|_| panic!("Update {config_file_name} with the default config values")); config_path.pop();
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1708118210077285516_25_30
clm
snippet
// connector-service/backend/grpc-server/src/main.rs fn verify_other_config_files() { use std::path::PathBuf; use crate::configs; let config_file_names = vec!["production.toml", "sandbox.toml"]; let mut config_path = PathBuf::new(); config_path.push(configs::workspace_path()); let config_directory: String = "config".into(); config_path.push(config_directory); for config_file_name in config_file_names { config_path.push(config_file_name); #[allow(clippy::panic)] let _ = configs::Config::new_with_config_path(Some(config_path.clone())) .unwrap_or_else(|_| panic!("Update {config_file_name} with the default config values")); config_path.pop(); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 17, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1708118210077285516_25_50
clm
snippet
// connector-service/backend/grpc-server/src/main.rs fn verify_other_config_files() { use std::path::PathBuf; use crate::configs; let config_file_names = vec!["production.toml", "sandbox.toml"]; let mut config_path = PathBuf::new(); config_path.push(configs::workspace_path()); let config_directory: String = "config".into(); config_path.push(config_directory); for config_file_name in config_file_names { config_path.push(config_file_name); #[allow(clippy::panic)] let _ = configs::Config::new_with_config_path(Some(config_path.clone())) .unwrap_or_else(|_| panic!("Update {config_file_name} with the default config values")); config_path.pop(); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 17, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_0_15
clm
snippet
// connector-service/backend/grpc-server/src/app.rs use std::{future::Future, net, sync::Arc}; use axum::{extract::Request, http}; use common_utils::consts; use external_services::shared_metrics as metrics; use grpc_api_types::{ health_check::health_server, payments::{ dispute_service_handler, dispute_service_server, payment_service_handler, payment_service_server, refund_service_handler, refund_service_server, }, }; use tokio::{ signal::unix::{signal, SignalKind}, sync::oneshot,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_0_30
clm
snippet
// connector-service/backend/grpc-server/src/app.rs use std::{future::Future, net, sync::Arc}; use axum::{extract::Request, http}; use common_utils::consts; use external_services::shared_metrics as metrics; use grpc_api_types::{ health_check::health_server, payments::{ dispute_service_handler, dispute_service_server, payment_service_handler, payment_service_server, refund_service_handler, refund_service_server, }, }; use tokio::{ signal::unix::{signal, SignalKind}, sync::oneshot, }; use tonic::transport::Server; use tower_http::{request_id::MakeRequestUuid, trace as tower_trace}; use crate::{configs, error::ConfigurationError, logger, utils}; /// # Panics /// /// Will panic if redis connection establishment fails or signal handling fails pub async fn server_builder(config: configs::Config) -> Result<(), ConfigurationError> { let server_config = config.server.clone(); let socket_addr = net::SocketAddr::new(server_config.host.parse()?, server_config.port); // Signal handler let (tx, rx) = oneshot::channel();
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_0_50
clm
snippet
// connector-service/backend/grpc-server/src/app.rs use std::{future::Future, net, sync::Arc}; use axum::{extract::Request, http}; use common_utils::consts; use external_services::shared_metrics as metrics; use grpc_api_types::{ health_check::health_server, payments::{ dispute_service_handler, dispute_service_server, payment_service_handler, payment_service_server, refund_service_handler, refund_service_server, }, }; use tokio::{ signal::unix::{signal, SignalKind}, sync::oneshot, }; use tonic::transport::Server; use tower_http::{request_id::MakeRequestUuid, trace as tower_trace}; use crate::{configs, error::ConfigurationError, logger, utils}; /// # Panics /// /// Will panic if redis connection establishment fails or signal handling fails pub async fn server_builder(config: configs::Config) -> Result<(), ConfigurationError> { let server_config = config.server.clone(); let socket_addr = net::SocketAddr::new(server_config.host.parse()?, server_config.port); // Signal handler let (tx, rx) = oneshot::channel(); #[allow(clippy::expect_used)] tokio::spawn(async move { let mut sig_int = signal(SignalKind::interrupt()).expect("Failed to initialize SIGINT signal handler"); let mut sig_term = signal(SignalKind::terminate()).expect("Failed to initialize SIGTERM signal handler"); let mut sig_quit = signal(SignalKind::quit()).expect("Failed to initialize QUIT signal handler"); let mut sig_hup = signal(SignalKind::hangup()).expect("Failed to initialize SIGHUP signal handler"); tokio::select! { _ = sig_int.recv() => { logger::info!("Received SIGINT"); tx.send(()).expect("Failed to send SIGINT signal"); } _ = sig_term.recv() => { logger::info!("Received SIGTERM"); tx.send(()).expect("Failed to send SIGTERM signal");
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_25_15
clm
snippet
// connector-service/backend/grpc-server/src/app.rs let server_config = config.server.clone(); let socket_addr = net::SocketAddr::new(server_config.host.parse()?, server_config.port); // Signal handler let (tx, rx) = oneshot::channel(); #[allow(clippy::expect_used)] tokio::spawn(async move { let mut sig_int = signal(SignalKind::interrupt()).expect("Failed to initialize SIGINT signal handler"); let mut sig_term = signal(SignalKind::terminate()).expect("Failed to initialize SIGTERM signal handler"); let mut sig_quit = signal(SignalKind::quit()).expect("Failed to initialize QUIT signal handler"); let mut sig_hup =
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_25_30
clm
snippet
// connector-service/backend/grpc-server/src/app.rs let server_config = config.server.clone(); let socket_addr = net::SocketAddr::new(server_config.host.parse()?, server_config.port); // Signal handler let (tx, rx) = oneshot::channel(); #[allow(clippy::expect_used)] tokio::spawn(async move { let mut sig_int = signal(SignalKind::interrupt()).expect("Failed to initialize SIGINT signal handler"); let mut sig_term = signal(SignalKind::terminate()).expect("Failed to initialize SIGTERM signal handler"); let mut sig_quit = signal(SignalKind::quit()).expect("Failed to initialize QUIT signal handler"); let mut sig_hup = signal(SignalKind::hangup()).expect("Failed to initialize SIGHUP signal handler"); tokio::select! { _ = sig_int.recv() => { logger::info!("Received SIGINT"); tx.send(()).expect("Failed to send SIGINT signal"); } _ = sig_term.recv() => { logger::info!("Received SIGTERM"); tx.send(()).expect("Failed to send SIGTERM signal"); } _ = sig_quit.recv() => { logger::info!("Received QUIT"); tx.send(()).expect("Failed to send QUIT signal"); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_25_50
clm
snippet
// connector-service/backend/grpc-server/src/app.rs let server_config = config.server.clone(); let socket_addr = net::SocketAddr::new(server_config.host.parse()?, server_config.port); // Signal handler let (tx, rx) = oneshot::channel(); #[allow(clippy::expect_used)] tokio::spawn(async move { let mut sig_int = signal(SignalKind::interrupt()).expect("Failed to initialize SIGINT signal handler"); let mut sig_term = signal(SignalKind::terminate()).expect("Failed to initialize SIGTERM signal handler"); let mut sig_quit = signal(SignalKind::quit()).expect("Failed to initialize QUIT signal handler"); let mut sig_hup = signal(SignalKind::hangup()).expect("Failed to initialize SIGHUP signal handler"); tokio::select! { _ = sig_int.recv() => { logger::info!("Received SIGINT"); tx.send(()).expect("Failed to send SIGINT signal"); } _ = sig_term.recv() => { logger::info!("Received SIGTERM"); tx.send(()).expect("Failed to send SIGTERM signal"); } _ = sig_quit.recv() => { logger::info!("Received QUIT"); tx.send(()).expect("Failed to send QUIT signal"); } _ = sig_hup.recv() => { logger::info!("Received SIGHUP"); tx.send(()).expect("Failed to send SIGHUP signal"); } } }); #[allow(clippy::expect_used)] let shutdown_signal = async { rx.await.expect("Failed to receive shutdown signal"); logger::info!("Shutdown signal received"); }; let service = Service::new(Arc::new(config)); logger::info!(host = %server_config.host, port = %server_config.port, r#type = ?server_config.type_, "starting connector service"); match server_config.type_ { configs::ServiceType::Grpc => { service
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_50_15
clm
snippet
// connector-service/backend/grpc-server/src/app.rs } _ = sig_quit.recv() => { logger::info!("Received QUIT"); tx.send(()).expect("Failed to send QUIT signal"); } _ = sig_hup.recv() => { logger::info!("Received SIGHUP"); tx.send(()).expect("Failed to send SIGHUP signal"); } } }); #[allow(clippy::expect_used)] let shutdown_signal = async { rx.await.expect("Failed to receive shutdown signal");
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_50_30
clm
snippet
// connector-service/backend/grpc-server/src/app.rs } _ = sig_quit.recv() => { logger::info!("Received QUIT"); tx.send(()).expect("Failed to send QUIT signal"); } _ = sig_hup.recv() => { logger::info!("Received SIGHUP"); tx.send(()).expect("Failed to send SIGHUP signal"); } } }); #[allow(clippy::expect_used)] let shutdown_signal = async { rx.await.expect("Failed to receive shutdown signal"); logger::info!("Shutdown signal received"); }; let service = Service::new(Arc::new(config)); logger::info!(host = %server_config.host, port = %server_config.port, r#type = ?server_config.type_, "starting connector service"); match server_config.type_ { configs::ServiceType::Grpc => { service .await .grpc_server(socket_addr, shutdown_signal) .await? } configs::ServiceType::Http => {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_50_50
clm
snippet
// connector-service/backend/grpc-server/src/app.rs } _ = sig_quit.recv() => { logger::info!("Received QUIT"); tx.send(()).expect("Failed to send QUIT signal"); } _ = sig_hup.recv() => { logger::info!("Received SIGHUP"); tx.send(()).expect("Failed to send SIGHUP signal"); } } }); #[allow(clippy::expect_used)] let shutdown_signal = async { rx.await.expect("Failed to receive shutdown signal"); logger::info!("Shutdown signal received"); }; let service = Service::new(Arc::new(config)); logger::info!(host = %server_config.host, port = %server_config.port, r#type = ?server_config.type_, "starting connector service"); match server_config.type_ { configs::ServiceType::Grpc => { service .await .grpc_server(socket_addr, shutdown_signal) .await? } configs::ServiceType::Http => { service .await .http_server(socket_addr, shutdown_signal) .await? } } Ok(()) } pub struct Service { pub health_check_service: crate::server::health_check::HealthCheck, pub payments_service: crate::server::payments::Payments, pub refunds_service: crate::server::refunds::Refunds, pub disputes_service: crate::server::disputes::Disputes, } impl Service { /// # Panics ///
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_75_15
clm
snippet
// connector-service/backend/grpc-server/src/app.rs .await .grpc_server(socket_addr, shutdown_signal) .await? } configs::ServiceType::Http => { service .await .http_server(socket_addr, shutdown_signal) .await? } } Ok(()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_75_30
clm
snippet
// connector-service/backend/grpc-server/src/app.rs .await .grpc_server(socket_addr, shutdown_signal) .await? } configs::ServiceType::Http => { service .await .http_server(socket_addr, shutdown_signal) .await? } } Ok(()) } pub struct Service { pub health_check_service: crate::server::health_check::HealthCheck, pub payments_service: crate::server::payments::Payments, pub refunds_service: crate::server::refunds::Refunds, pub disputes_service: crate::server::disputes::Disputes, } impl Service { /// # Panics /// /// Will panic if EventPublisher initialization fails, database password, hash key isn't present in configs or unable to /// deserialize any of the above keys #[allow(clippy::expect_used)] pub async fn new(config: Arc<configs::Config>) -> Self { // Initialize the global EventPublisher - fail fast on startup
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_75_50
clm
snippet
// connector-service/backend/grpc-server/src/app.rs .await .grpc_server(socket_addr, shutdown_signal) .await? } configs::ServiceType::Http => { service .await .http_server(socket_addr, shutdown_signal) .await? } } Ok(()) } pub struct Service { pub health_check_service: crate::server::health_check::HealthCheck, pub payments_service: crate::server::payments::Payments, pub refunds_service: crate::server::refunds::Refunds, pub disputes_service: crate::server::disputes::Disputes, } impl Service { /// # Panics /// /// Will panic if EventPublisher initialization fails, database password, hash key isn't present in configs or unable to /// deserialize any of the above keys #[allow(clippy::expect_used)] pub async fn new(config: Arc<configs::Config>) -> Self { // Initialize the global EventPublisher - fail fast on startup if config.events.enabled { common_utils::init_event_publisher(&config.events) .expect("Failed to initialize global EventPublisher during startup"); logger::info!("Global EventPublisher initialized successfully"); } else { logger::info!("EventPublisher disabled in configuration"); } Self { health_check_service: crate::server::health_check::HealthCheck, payments_service: crate::server::payments::Payments { config: Arc::clone(&config), }, refunds_service: crate::server::refunds::Refunds { config: Arc::clone(&config), }, disputes_service: crate::server::disputes::Disputes { config }, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_100_15
clm
snippet
// connector-service/backend/grpc-server/src/app.rs /// Will panic if EventPublisher initialization fails, database password, hash key isn't present in configs or unable to /// deserialize any of the above keys #[allow(clippy::expect_used)] pub async fn new(config: Arc<configs::Config>) -> Self { // Initialize the global EventPublisher - fail fast on startup if config.events.enabled { common_utils::init_event_publisher(&config.events) .expect("Failed to initialize global EventPublisher during startup"); logger::info!("Global EventPublisher initialized successfully"); } else { logger::info!("EventPublisher disabled in configuration"); } Self { health_check_service: crate::server::health_check::HealthCheck,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_100_30
clm
snippet
// connector-service/backend/grpc-server/src/app.rs /// Will panic if EventPublisher initialization fails, database password, hash key isn't present in configs or unable to /// deserialize any of the above keys #[allow(clippy::expect_used)] pub async fn new(config: Arc<configs::Config>) -> Self { // Initialize the global EventPublisher - fail fast on startup if config.events.enabled { common_utils::init_event_publisher(&config.events) .expect("Failed to initialize global EventPublisher during startup"); logger::info!("Global EventPublisher initialized successfully"); } else { logger::info!("EventPublisher disabled in configuration"); } Self { health_check_service: crate::server::health_check::HealthCheck, payments_service: crate::server::payments::Payments { config: Arc::clone(&config), }, refunds_service: crate::server::refunds::Refunds { config: Arc::clone(&config), }, disputes_service: crate::server::disputes::Disputes { config }, } } pub async fn http_server( self, socket: net::SocketAddr, shutdown_signal: impl Future<Output = ()> + Send + 'static, ) -> Result<(), ConfigurationError> {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_100_50
clm
snippet
// connector-service/backend/grpc-server/src/app.rs /// Will panic if EventPublisher initialization fails, database password, hash key isn't present in configs or unable to /// deserialize any of the above keys #[allow(clippy::expect_used)] pub async fn new(config: Arc<configs::Config>) -> Self { // Initialize the global EventPublisher - fail fast on startup if config.events.enabled { common_utils::init_event_publisher(&config.events) .expect("Failed to initialize global EventPublisher during startup"); logger::info!("Global EventPublisher initialized successfully"); } else { logger::info!("EventPublisher disabled in configuration"); } Self { health_check_service: crate::server::health_check::HealthCheck, payments_service: crate::server::payments::Payments { config: Arc::clone(&config), }, refunds_service: crate::server::refunds::Refunds { config: Arc::clone(&config), }, disputes_service: crate::server::disputes::Disputes { config }, } } pub async fn http_server( self, socket: net::SocketAddr, shutdown_signal: impl Future<Output = ()> + Send + 'static, ) -> Result<(), ConfigurationError> { let logging_layer = tower_trace::TraceLayer::new_for_http() .make_span_with(|request: &Request<_>| utils::record_fields_from_header(request)) .on_request(tower_trace::DefaultOnRequest::new().level(tracing::Level::INFO)) .on_response( tower_trace::DefaultOnResponse::new() .level(tracing::Level::INFO) .latency_unit(tower_http::LatencyUnit::Micros), ) .on_failure( tower_trace::DefaultOnFailure::new() .latency_unit(tower_http::LatencyUnit::Micros) .level(tracing::Level::ERROR), ); let request_id_layer = tower_http::request_id::SetRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), MakeRequestUuid, ); let propagate_request_id_layer = tower_http::request_id::PropagateRequestIdLayer::new(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_125_15
clm
snippet
// connector-service/backend/grpc-server/src/app.rs pub async fn http_server( self, socket: net::SocketAddr, shutdown_signal: impl Future<Output = ()> + Send + 'static, ) -> Result<(), ConfigurationError> { let logging_layer = tower_trace::TraceLayer::new_for_http() .make_span_with(|request: &Request<_>| utils::record_fields_from_header(request)) .on_request(tower_trace::DefaultOnRequest::new().level(tracing::Level::INFO)) .on_response( tower_trace::DefaultOnResponse::new() .level(tracing::Level::INFO) .latency_unit(tower_http::LatencyUnit::Micros), ) .on_failure( tower_trace::DefaultOnFailure::new()
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_125_30
clm
snippet
// connector-service/backend/grpc-server/src/app.rs pub async fn http_server( self, socket: net::SocketAddr, shutdown_signal: impl Future<Output = ()> + Send + 'static, ) -> Result<(), ConfigurationError> { let logging_layer = tower_trace::TraceLayer::new_for_http() .make_span_with(|request: &Request<_>| utils::record_fields_from_header(request)) .on_request(tower_trace::DefaultOnRequest::new().level(tracing::Level::INFO)) .on_response( tower_trace::DefaultOnResponse::new() .level(tracing::Level::INFO) .latency_unit(tower_http::LatencyUnit::Micros), ) .on_failure( tower_trace::DefaultOnFailure::new() .latency_unit(tower_http::LatencyUnit::Micros) .level(tracing::Level::ERROR), ); let request_id_layer = tower_http::request_id::SetRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), MakeRequestUuid, ); let propagate_request_id_layer = tower_http::request_id::PropagateRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), ); let router = axum::Router::new() .route("/health", axum::routing::get(|| async { "health is good" }))
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_125_50
clm
snippet
// connector-service/backend/grpc-server/src/app.rs pub async fn http_server( self, socket: net::SocketAddr, shutdown_signal: impl Future<Output = ()> + Send + 'static, ) -> Result<(), ConfigurationError> { let logging_layer = tower_trace::TraceLayer::new_for_http() .make_span_with(|request: &Request<_>| utils::record_fields_from_header(request)) .on_request(tower_trace::DefaultOnRequest::new().level(tracing::Level::INFO)) .on_response( tower_trace::DefaultOnResponse::new() .level(tracing::Level::INFO) .latency_unit(tower_http::LatencyUnit::Micros), ) .on_failure( tower_trace::DefaultOnFailure::new() .latency_unit(tower_http::LatencyUnit::Micros) .level(tracing::Level::ERROR), ); let request_id_layer = tower_http::request_id::SetRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), MakeRequestUuid, ); let propagate_request_id_layer = tower_http::request_id::PropagateRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), ); let router = axum::Router::new() .route("/health", axum::routing::get(|| async { "health is good" })) .merge(payment_service_handler(self.payments_service)) .merge(refund_service_handler(self.refunds_service)) .merge(dispute_service_handler(self.disputes_service)) .layer(logging_layer) .layer(request_id_layer) .layer(propagate_request_id_layer); let listener = tokio::net::TcpListener::bind(socket).await?; axum::serve(listener, router.into_make_service()) .with_graceful_shutdown(shutdown_signal) .await?; Ok(()) } pub async fn grpc_server( self, socket: net::SocketAddr, shutdown_signal: impl Future<Output = ()>,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_150_15
clm
snippet
// connector-service/backend/grpc-server/src/app.rs http::HeaderName::from_static(consts::X_REQUEST_ID), ); let router = axum::Router::new() .route("/health", axum::routing::get(|| async { "health is good" })) .merge(payment_service_handler(self.payments_service)) .merge(refund_service_handler(self.refunds_service)) .merge(dispute_service_handler(self.disputes_service)) .layer(logging_layer) .layer(request_id_layer) .layer(propagate_request_id_layer); let listener = tokio::net::TcpListener::bind(socket).await?; axum::serve(listener, router.into_make_service())
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_150_30
clm
snippet
// connector-service/backend/grpc-server/src/app.rs http::HeaderName::from_static(consts::X_REQUEST_ID), ); let router = axum::Router::new() .route("/health", axum::routing::get(|| async { "health is good" })) .merge(payment_service_handler(self.payments_service)) .merge(refund_service_handler(self.refunds_service)) .merge(dispute_service_handler(self.disputes_service)) .layer(logging_layer) .layer(request_id_layer) .layer(propagate_request_id_layer); let listener = tokio::net::TcpListener::bind(socket).await?; axum::serve(listener, router.into_make_service()) .with_graceful_shutdown(shutdown_signal) .await?; Ok(()) } pub async fn grpc_server( self, socket: net::SocketAddr, shutdown_signal: impl Future<Output = ()>, ) -> Result<(), ConfigurationError> { let reflection_service = tonic_reflection::server::Builder::configure() .register_encoded_file_descriptor_set(grpc_api_types::FILE_DESCRIPTOR_SET) .build_v1()?;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_150_50
clm
snippet
// connector-service/backend/grpc-server/src/app.rs http::HeaderName::from_static(consts::X_REQUEST_ID), ); let router = axum::Router::new() .route("/health", axum::routing::get(|| async { "health is good" })) .merge(payment_service_handler(self.payments_service)) .merge(refund_service_handler(self.refunds_service)) .merge(dispute_service_handler(self.disputes_service)) .layer(logging_layer) .layer(request_id_layer) .layer(propagate_request_id_layer); let listener = tokio::net::TcpListener::bind(socket).await?; axum::serve(listener, router.into_make_service()) .with_graceful_shutdown(shutdown_signal) .await?; Ok(()) } pub async fn grpc_server( self, socket: net::SocketAddr, shutdown_signal: impl Future<Output = ()>, ) -> Result<(), ConfigurationError> { let reflection_service = tonic_reflection::server::Builder::configure() .register_encoded_file_descriptor_set(grpc_api_types::FILE_DESCRIPTOR_SET) .build_v1()?; let logging_layer = tower_trace::TraceLayer::new_for_http() .make_span_with(|request: &http::request::Request<_>| { utils::record_fields_from_header(request) }) .on_request(tower_trace::DefaultOnRequest::new().level(tracing::Level::INFO)) .on_response( tower_trace::DefaultOnResponse::new() .level(tracing::Level::INFO) .latency_unit(tower_http::LatencyUnit::Micros), ) .on_failure( tower_trace::DefaultOnFailure::new() .latency_unit(tower_http::LatencyUnit::Micros) .level(tracing::Level::ERROR), ); let metrics_layer = metrics::GrpcMetricsLayer::new(); let request_id_layer = tower_http::request_id::SetRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_175_15
clm
snippet
// connector-service/backend/grpc-server/src/app.rs ) -> Result<(), ConfigurationError> { let reflection_service = tonic_reflection::server::Builder::configure() .register_encoded_file_descriptor_set(grpc_api_types::FILE_DESCRIPTOR_SET) .build_v1()?; let logging_layer = tower_trace::TraceLayer::new_for_http() .make_span_with(|request: &http::request::Request<_>| { utils::record_fields_from_header(request) }) .on_request(tower_trace::DefaultOnRequest::new().level(tracing::Level::INFO)) .on_response( tower_trace::DefaultOnResponse::new() .level(tracing::Level::INFO) .latency_unit(tower_http::LatencyUnit::Micros), )
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_175_30
clm
snippet
// connector-service/backend/grpc-server/src/app.rs ) -> Result<(), ConfigurationError> { let reflection_service = tonic_reflection::server::Builder::configure() .register_encoded_file_descriptor_set(grpc_api_types::FILE_DESCRIPTOR_SET) .build_v1()?; let logging_layer = tower_trace::TraceLayer::new_for_http() .make_span_with(|request: &http::request::Request<_>| { utils::record_fields_from_header(request) }) .on_request(tower_trace::DefaultOnRequest::new().level(tracing::Level::INFO)) .on_response( tower_trace::DefaultOnResponse::new() .level(tracing::Level::INFO) .latency_unit(tower_http::LatencyUnit::Micros), ) .on_failure( tower_trace::DefaultOnFailure::new() .latency_unit(tower_http::LatencyUnit::Micros) .level(tracing::Level::ERROR), ); let metrics_layer = metrics::GrpcMetricsLayer::new(); let request_id_layer = tower_http::request_id::SetRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), MakeRequestUuid, ); let propagate_request_id_layer = tower_http::request_id::PropagateRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), );
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_175_50
clm
snippet
// connector-service/backend/grpc-server/src/app.rs ) -> Result<(), ConfigurationError> { let reflection_service = tonic_reflection::server::Builder::configure() .register_encoded_file_descriptor_set(grpc_api_types::FILE_DESCRIPTOR_SET) .build_v1()?; let logging_layer = tower_trace::TraceLayer::new_for_http() .make_span_with(|request: &http::request::Request<_>| { utils::record_fields_from_header(request) }) .on_request(tower_trace::DefaultOnRequest::new().level(tracing::Level::INFO)) .on_response( tower_trace::DefaultOnResponse::new() .level(tracing::Level::INFO) .latency_unit(tower_http::LatencyUnit::Micros), ) .on_failure( tower_trace::DefaultOnFailure::new() .latency_unit(tower_http::LatencyUnit::Micros) .level(tracing::Level::ERROR), ); let metrics_layer = metrics::GrpcMetricsLayer::new(); let request_id_layer = tower_http::request_id::SetRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), MakeRequestUuid, ); let propagate_request_id_layer = tower_http::request_id::PropagateRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), ); Server::builder() .layer(logging_layer) .layer(request_id_layer) .layer(propagate_request_id_layer) .layer(metrics_layer) .add_service(reflection_service) .add_service(health_server::HealthServer::new(self.health_check_service)) .add_service(payment_service_server::PaymentServiceServer::new( self.payments_service.clone(), )) .add_service(refund_service_server::RefundServiceServer::new( self.refunds_service, )) .add_service(dispute_service_server::DisputeServiceServer::new( self.disputes_service, )) .serve_with_shutdown(socket, shutdown_signal) .await?;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_200_15
clm
snippet
// connector-service/backend/grpc-server/src/app.rs MakeRequestUuid, ); let propagate_request_id_layer = tower_http::request_id::PropagateRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), ); Server::builder() .layer(logging_layer) .layer(request_id_layer) .layer(propagate_request_id_layer) .layer(metrics_layer) .add_service(reflection_service) .add_service(health_server::HealthServer::new(self.health_check_service)) .add_service(payment_service_server::PaymentServiceServer::new( self.payments_service.clone(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_200_30
clm
snippet
// connector-service/backend/grpc-server/src/app.rs MakeRequestUuid, ); let propagate_request_id_layer = tower_http::request_id::PropagateRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), ); Server::builder() .layer(logging_layer) .layer(request_id_layer) .layer(propagate_request_id_layer) .layer(metrics_layer) .add_service(reflection_service) .add_service(health_server::HealthServer::new(self.health_check_service)) .add_service(payment_service_server::PaymentServiceServer::new( self.payments_service.clone(), )) .add_service(refund_service_server::RefundServiceServer::new( self.refunds_service, )) .add_service(dispute_service_server::DisputeServiceServer::new( self.disputes_service, )) .serve_with_shutdown(socket, shutdown_signal) .await?; Ok(()) } } pub async fn metrics_server_builder(config: configs::Config) -> Result<(), ConfigurationError> {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_200_50
clm
snippet
// connector-service/backend/grpc-server/src/app.rs MakeRequestUuid, ); let propagate_request_id_layer = tower_http::request_id::PropagateRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), ); Server::builder() .layer(logging_layer) .layer(request_id_layer) .layer(propagate_request_id_layer) .layer(metrics_layer) .add_service(reflection_service) .add_service(health_server::HealthServer::new(self.health_check_service)) .add_service(payment_service_server::PaymentServiceServer::new( self.payments_service.clone(), )) .add_service(refund_service_server::RefundServiceServer::new( self.refunds_service, )) .add_service(dispute_service_server::DisputeServiceServer::new( self.disputes_service, )) .serve_with_shutdown(socket, shutdown_signal) .await?; Ok(()) } } pub async fn metrics_server_builder(config: configs::Config) -> Result<(), ConfigurationError> { let listener = config.metrics.tcp_listener().await?; let router = axum::Router::new().route( "/metrics", axum::routing::get(|| async { let output = metrics::metrics_handler().await; match output { Ok(metrics) => Ok(metrics), Err(error) => { tracing::error!(?error, "Error fetching metrics"); Err(( http::StatusCode::INTERNAL_SERVER_ERROR, "Error fetching metrics".to_string(), )) } } }), );
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_225_15
clm
snippet
// connector-service/backend/grpc-server/src/app.rs Ok(()) } } pub async fn metrics_server_builder(config: configs::Config) -> Result<(), ConfigurationError> { let listener = config.metrics.tcp_listener().await?; let router = axum::Router::new().route( "/metrics", axum::routing::get(|| async { let output = metrics::metrics_handler().await; match output { Ok(metrics) => Ok(metrics), Err(error) => { tracing::error!(?error, "Error fetching metrics");
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_225_30
clm
snippet
// connector-service/backend/grpc-server/src/app.rs Ok(()) } } pub async fn metrics_server_builder(config: configs::Config) -> Result<(), ConfigurationError> { let listener = config.metrics.tcp_listener().await?; let router = axum::Router::new().route( "/metrics", axum::routing::get(|| async { let output = metrics::metrics_handler().await; match output { Ok(metrics) => Ok(metrics), Err(error) => { tracing::error!(?error, "Error fetching metrics"); Err(( http::StatusCode::INTERNAL_SERVER_ERROR, "Error fetching metrics".to_string(), )) } } }), ); axum::serve(listener, router.into_make_service()) .with_graceful_shutdown(async { let output = tokio::signal::ctrl_c().await; tracing::error!(?output, "shutting down"); })
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-2612312103591988008_225_50
clm
snippet
// connector-service/backend/grpc-server/src/app.rs Ok(()) } } pub async fn metrics_server_builder(config: configs::Config) -> Result<(), ConfigurationError> { let listener = config.metrics.tcp_listener().await?; let router = axum::Router::new().route( "/metrics", axum::routing::get(|| async { let output = metrics::metrics_handler().await; match output { Ok(metrics) => Ok(metrics), Err(error) => { tracing::error!(?error, "Error fetching metrics"); Err(( http::StatusCode::INTERNAL_SERVER_ERROR, "Error fetching metrics".to_string(), )) } } }), ); axum::serve(listener, router.into_make_service()) .with_graceful_shutdown(async { let output = tokio::signal::ctrl_c().await; tracing::error!(?output, "shutting down"); }) .await?; Ok(()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 34, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_4018572258718428657_0_15
clm
snippet
// connector-service/backend/grpc-server/src/utils.rs use std::{str::FromStr, sync::Arc}; use common_utils::{ consts::{ self, X_API_KEY, X_API_SECRET, X_AUTH, X_AUTH_KEY_MAP, X_KEY1, X_KEY2, X_SHADOW_MODE, }, errors::CustomResult, events::{Event, EventStage, FlowName, MaskedSerdeValue}, lineage::LineageIds, }; use domain_types::{ connector_flow::{ Accept, Authenticate, Authorize, Capture, CreateOrder, CreateSessionToken, DefendDispute, PSync, PaymentMethodToken, PostAuthenticate, PreAuthenticate, RSync, Refund, RepeatPayment, SetupMandate, SubmitEvidence, Void, VoidPC,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_4018572258718428657_0_30
clm
snippet
// connector-service/backend/grpc-server/src/utils.rs use std::{str::FromStr, sync::Arc}; use common_utils::{ consts::{ self, X_API_KEY, X_API_SECRET, X_AUTH, X_AUTH_KEY_MAP, X_KEY1, X_KEY2, X_SHADOW_MODE, }, errors::CustomResult, events::{Event, EventStage, FlowName, MaskedSerdeValue}, lineage::LineageIds, }; use domain_types::{ connector_flow::{ Accept, Authenticate, Authorize, Capture, CreateOrder, CreateSessionToken, DefendDispute, PSync, PaymentMethodToken, PostAuthenticate, PreAuthenticate, RSync, Refund, RepeatPayment, SetupMandate, SubmitEvidence, Void, VoidPC, }, connector_types, errors::{ApiError, ApplicationErrorResponse}, router_data::ConnectorAuthType, }; use error_stack::{Report, ResultExt}; use http::request::Request; use hyperswitch_masking; use tonic::metadata; use crate::{configs, error::ResultExtGrpc, request::RequestData}; use std::collections::HashMap; // Helper function to map flow markers to flow names pub fn flow_marker_to_flow_name<F>() -> FlowName
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_4018572258718428657_0_50
clm
snippet
// connector-service/backend/grpc-server/src/utils.rs use std::{str::FromStr, sync::Arc}; use common_utils::{ consts::{ self, X_API_KEY, X_API_SECRET, X_AUTH, X_AUTH_KEY_MAP, X_KEY1, X_KEY2, X_SHADOW_MODE, }, errors::CustomResult, events::{Event, EventStage, FlowName, MaskedSerdeValue}, lineage::LineageIds, }; use domain_types::{ connector_flow::{ Accept, Authenticate, Authorize, Capture, CreateOrder, CreateSessionToken, DefendDispute, PSync, PaymentMethodToken, PostAuthenticate, PreAuthenticate, RSync, Refund, RepeatPayment, SetupMandate, SubmitEvidence, Void, VoidPC, }, connector_types, errors::{ApiError, ApplicationErrorResponse}, router_data::ConnectorAuthType, }; use error_stack::{Report, ResultExt}; use http::request::Request; use hyperswitch_masking; use tonic::metadata; use crate::{configs, error::ResultExtGrpc, request::RequestData}; use std::collections::HashMap; // Helper function to map flow markers to flow names pub fn flow_marker_to_flow_name<F>() -> FlowName where F: 'static, { let type_id = std::any::TypeId::of::<F>(); if type_id == std::any::TypeId::of::<Authorize>() { FlowName::Authorize } else if type_id == std::any::TypeId::of::<PSync>() { FlowName::Psync } else if type_id == std::any::TypeId::of::<RSync>() { FlowName::Rsync } else if type_id == std::any::TypeId::of::<Void>() { FlowName::Void } else if type_id == std::any::TypeId::of::<VoidPC>() { FlowName::VoidPostCapture } else if type_id == std::any::TypeId::of::<Refund>() { FlowName::Refund } else if type_id == std::any::TypeId::of::<Capture>() { FlowName::Capture } else if type_id == std::any::TypeId::of::<SetupMandate>() {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_4018572258718428657_25_15
clm
snippet
// connector-service/backend/grpc-server/src/utils.rs use crate::{configs, error::ResultExtGrpc, request::RequestData}; use std::collections::HashMap; // Helper function to map flow markers to flow names pub fn flow_marker_to_flow_name<F>() -> FlowName where F: 'static, { let type_id = std::any::TypeId::of::<F>(); if type_id == std::any::TypeId::of::<Authorize>() { FlowName::Authorize } else if type_id == std::any::TypeId::of::<PSync>() { FlowName::Psync } else if type_id == std::any::TypeId::of::<RSync>() {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_4018572258718428657_25_30
clm
snippet
// connector-service/backend/grpc-server/src/utils.rs use crate::{configs, error::ResultExtGrpc, request::RequestData}; use std::collections::HashMap; // Helper function to map flow markers to flow names pub fn flow_marker_to_flow_name<F>() -> FlowName where F: 'static, { let type_id = std::any::TypeId::of::<F>(); if type_id == std::any::TypeId::of::<Authorize>() { FlowName::Authorize } else if type_id == std::any::TypeId::of::<PSync>() { FlowName::Psync } else if type_id == std::any::TypeId::of::<RSync>() { FlowName::Rsync } else if type_id == std::any::TypeId::of::<Void>() { FlowName::Void } else if type_id == std::any::TypeId::of::<VoidPC>() { FlowName::VoidPostCapture } else if type_id == std::any::TypeId::of::<Refund>() { FlowName::Refund } else if type_id == std::any::TypeId::of::<Capture>() { FlowName::Capture } else if type_id == std::any::TypeId::of::<SetupMandate>() { FlowName::SetupMandate } else if type_id == std::any::TypeId::of::<RepeatPayment>() { FlowName::RepeatPayment } else if type_id == std::any::TypeId::of::<CreateOrder>() { FlowName::CreateOrder
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_4018572258718428657_25_50
clm
snippet
// connector-service/backend/grpc-server/src/utils.rs use crate::{configs, error::ResultExtGrpc, request::RequestData}; use std::collections::HashMap; // Helper function to map flow markers to flow names pub fn flow_marker_to_flow_name<F>() -> FlowName where F: 'static, { let type_id = std::any::TypeId::of::<F>(); if type_id == std::any::TypeId::of::<Authorize>() { FlowName::Authorize } else if type_id == std::any::TypeId::of::<PSync>() { FlowName::Psync } else if type_id == std::any::TypeId::of::<RSync>() { FlowName::Rsync } else if type_id == std::any::TypeId::of::<Void>() { FlowName::Void } else if type_id == std::any::TypeId::of::<VoidPC>() { FlowName::VoidPostCapture } else if type_id == std::any::TypeId::of::<Refund>() { FlowName::Refund } else if type_id == std::any::TypeId::of::<Capture>() { FlowName::Capture } else if type_id == std::any::TypeId::of::<SetupMandate>() { FlowName::SetupMandate } else if type_id == std::any::TypeId::of::<RepeatPayment>() { FlowName::RepeatPayment } else if type_id == std::any::TypeId::of::<CreateOrder>() { FlowName::CreateOrder } else if type_id == std::any::TypeId::of::<CreateSessionToken>() { FlowName::CreateSessionToken } else if type_id == std::any::TypeId::of::<Accept>() { FlowName::AcceptDispute } else if type_id == std::any::TypeId::of::<DefendDispute>() { FlowName::DefendDispute } else if type_id == std::any::TypeId::of::<SubmitEvidence>() { FlowName::SubmitEvidence } else if type_id == std::any::TypeId::of::<PaymentMethodToken>() { FlowName::PaymentMethodToken } else if type_id == std::any::TypeId::of::<PreAuthenticate>() { FlowName::PreAuthenticate } else if type_id == std::any::TypeId::of::<Authenticate>() { FlowName::Authenticate } else if type_id == std::any::TypeId::of::<PostAuthenticate>() { FlowName::PostAuthenticate } else { tracing::warn!("Unknown flow marker type: {}", std::any::type_name::<F>()); FlowName::Unknown }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_4018572258718428657_50_15
clm
snippet
// connector-service/backend/grpc-server/src/utils.rs FlowName::SetupMandate } else if type_id == std::any::TypeId::of::<RepeatPayment>() { FlowName::RepeatPayment } else if type_id == std::any::TypeId::of::<CreateOrder>() { FlowName::CreateOrder } else if type_id == std::any::TypeId::of::<CreateSessionToken>() { FlowName::CreateSessionToken } else if type_id == std::any::TypeId::of::<Accept>() { FlowName::AcceptDispute } else if type_id == std::any::TypeId::of::<DefendDispute>() { FlowName::DefendDispute } else if type_id == std::any::TypeId::of::<SubmitEvidence>() { FlowName::SubmitEvidence } else if type_id == std::any::TypeId::of::<PaymentMethodToken>() { FlowName::PaymentMethodToken
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_4018572258718428657_50_30
clm
snippet
// connector-service/backend/grpc-server/src/utils.rs FlowName::SetupMandate } else if type_id == std::any::TypeId::of::<RepeatPayment>() { FlowName::RepeatPayment } else if type_id == std::any::TypeId::of::<CreateOrder>() { FlowName::CreateOrder } else if type_id == std::any::TypeId::of::<CreateSessionToken>() { FlowName::CreateSessionToken } else if type_id == std::any::TypeId::of::<Accept>() { FlowName::AcceptDispute } else if type_id == std::any::TypeId::of::<DefendDispute>() { FlowName::DefendDispute } else if type_id == std::any::TypeId::of::<SubmitEvidence>() { FlowName::SubmitEvidence } else if type_id == std::any::TypeId::of::<PaymentMethodToken>() { FlowName::PaymentMethodToken } else if type_id == std::any::TypeId::of::<PreAuthenticate>() { FlowName::PreAuthenticate } else if type_id == std::any::TypeId::of::<Authenticate>() { FlowName::Authenticate } else if type_id == std::any::TypeId::of::<PostAuthenticate>() { FlowName::PostAuthenticate } else { tracing::warn!("Unknown flow marker type: {}", std::any::type_name::<F>()); FlowName::Unknown } } /// Extract lineage fields from header pub fn extract_lineage_fields_from_metadata( metadata: &metadata::MetadataMap,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_4018572258718428657_50_50
clm
snippet
// connector-service/backend/grpc-server/src/utils.rs FlowName::SetupMandate } else if type_id == std::any::TypeId::of::<RepeatPayment>() { FlowName::RepeatPayment } else if type_id == std::any::TypeId::of::<CreateOrder>() { FlowName::CreateOrder } else if type_id == std::any::TypeId::of::<CreateSessionToken>() { FlowName::CreateSessionToken } else if type_id == std::any::TypeId::of::<Accept>() { FlowName::AcceptDispute } else if type_id == std::any::TypeId::of::<DefendDispute>() { FlowName::DefendDispute } else if type_id == std::any::TypeId::of::<SubmitEvidence>() { FlowName::SubmitEvidence } else if type_id == std::any::TypeId::of::<PaymentMethodToken>() { FlowName::PaymentMethodToken } else if type_id == std::any::TypeId::of::<PreAuthenticate>() { FlowName::PreAuthenticate } else if type_id == std::any::TypeId::of::<Authenticate>() { FlowName::Authenticate } else if type_id == std::any::TypeId::of::<PostAuthenticate>() { FlowName::PostAuthenticate } else { tracing::warn!("Unknown flow marker type: {}", std::any::type_name::<F>()); FlowName::Unknown } } /// Extract lineage fields from header pub fn extract_lineage_fields_from_metadata( metadata: &metadata::MetadataMap, config: &configs::LineageConfig, ) -> LineageIds<'static> { if !config.enabled { return LineageIds::empty(&config.field_prefix).to_owned(); } metadata .get(&config.header_name) .and_then(|value| value.to_str().ok()) .map(|header_value| LineageIds::new(&config.field_prefix, header_value)) .transpose() .inspect(|value| { tracing::info!( parsed_fields = ?value, "Successfully parsed lineage header" ) }) .inspect_err(|err| { tracing::warn!( error = %err, "Failed to parse lineage header, continuing without lineage fields"
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }