mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 05:44:20 +01:00
Add Service Status page with service_health_check and report_issue examples
This commit is contained in:
36
snippets/csharp/ServiceStatus.cs
Normal file
36
snippets/csharp/ServiceStatus.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using Breez.Sdk;
|
||||||
|
|
||||||
|
public class ServiceStatusSnippets
|
||||||
|
{
|
||||||
|
public void HealthCheckStatus(BlockingBreezServices sdk)
|
||||||
|
{
|
||||||
|
// ANCHOR: health-check-status
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var healthCheck = sdk.ServiceHealthCheck();
|
||||||
|
Console.WriteLine($"Current service status is: {currentFees.totalEstimatedFees}");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: health-check-status
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReportPaymentFailure(BlockingBreezServices sdk)
|
||||||
|
{
|
||||||
|
// ANCHOR: report-payment-failure
|
||||||
|
var paymentHash = "...";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sdk.ReportIssue(new ReportIssueRequest.PaymentFailure(
|
||||||
|
new ReportPaymentFailureDetails(paymentHash)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: report-payment-failure
|
||||||
|
}
|
||||||
|
}
|
||||||
16
snippets/dart_snippets/lib/service_status.dart
Normal file
16
snippets/dart_snippets/lib/service_status.dart
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import 'package:breez_sdk/breez_sdk.dart';
|
||||||
|
import 'package:breez_sdk/bridge_generated.dart';
|
||||||
|
|
||||||
|
Future<void> healthCheckStatus() async {
|
||||||
|
// ANCHOR: health-check-status
|
||||||
|
ServiceHealthCheckResponse healthCheck = await BreezSDK().serviceHealthCheck();
|
||||||
|
print("Current service status is: ${healthCheck.status}");
|
||||||
|
// ANCHOR_END: health-check-status
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> reportPaymentFailure() async {
|
||||||
|
// ANCHOR: report-payment-failure
|
||||||
|
String paymentHash = "...";
|
||||||
|
await BreezSDK().reportIssue(ReportIssueRequest.paymentFailure(paymentHash: paymentHash));
|
||||||
|
// ANCHOR_END: report-payment-failure
|
||||||
|
}
|
||||||
29
snippets/go/service_status.go
Normal file
29
snippets/go/service_status.go
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||||
|
)
|
||||||
|
|
||||||
|
func HealthCheckStatus() {
|
||||||
|
// ANCHOR: health-check-status
|
||||||
|
if healthCheck, err := sdk.ServiceHealthCheck(); err != nil {
|
||||||
|
log.Printf("Current service status is: %v", healthCheck.Status)
|
||||||
|
}
|
||||||
|
// ANCHOR_END: health-check-status
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReportPaymentFailure() {
|
||||||
|
// ANCHOR: report-payment-failure
|
||||||
|
paymentHash := "..."
|
||||||
|
reportIssueRequest := breez_sdk.ReportIssueRequestPaymentFailure{
|
||||||
|
Data: breez_sdk.ReportPaymentFailureDetails{
|
||||||
|
PaymentHash: paymentHash,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if err := sdk.ReportIssue(reportIssueRequest); err != nil {
|
||||||
|
log.Printf("%#v", err)
|
||||||
|
}
|
||||||
|
// ANCHOR_END: report-payment-failure
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.example.kotlinmpplib
|
||||||
|
|
||||||
|
import breez_sdk.*
|
||||||
|
class ConnectingLsp {
|
||||||
|
fun getServiceStatus(sdk: BlockingBreezServices) {
|
||||||
|
// ANCHOR: health-check-status
|
||||||
|
try {
|
||||||
|
val healthCheck = sdk.serviceHealthCheck()
|
||||||
|
// Log.v("Breez", "Current service status is: ${healthCheck.status}")
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: health-check-status
|
||||||
|
}
|
||||||
|
|
||||||
|
fun reportPaymentFailure(sdk: BlockingBreezServices) {
|
||||||
|
// ANCHOR: report-payment-failure
|
||||||
|
val paymentHash = "..."
|
||||||
|
try {
|
||||||
|
sdk.reportIssue(ReportIssueRequest.PaymentFailure(
|
||||||
|
ReportPaymentFailureDetails(paymentHash)))
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: report-payment-failure
|
||||||
|
}
|
||||||
|
}
|
||||||
23
snippets/python/src/service_status.py
Normal file
23
snippets/python/src/service_status.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import breez_sdk
|
||||||
|
|
||||||
|
def health_check_status(sdk_services):
|
||||||
|
try:
|
||||||
|
# ANCHOR: health-check-status
|
||||||
|
health_check = sdk_services.service_health_check()
|
||||||
|
print("Current service status is: ", health_check.status)
|
||||||
|
# ANCHOR_END: health-check-status
|
||||||
|
except Exception as error:
|
||||||
|
print(error)
|
||||||
|
raise
|
||||||
|
|
||||||
|
def report_payment_failure(sdk_services):
|
||||||
|
try:
|
||||||
|
# ANCHOR: report-payment-failure
|
||||||
|
payment_hash = "..."
|
||||||
|
sdk_services.report_issue(
|
||||||
|
breez_sdk.ReportIssueRequest.PAYMENT_FAILURE(
|
||||||
|
breez_sdk.ReportPaymentFailureDetails(payment_hash)))
|
||||||
|
# ANCHOR_END: report-payment-failure
|
||||||
|
except Exception as error:
|
||||||
|
print(error)
|
||||||
|
raise
|
||||||
18
snippets/react-native/service_status.ts
Normal file
18
snippets/react-native/service_status.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { serviceHealthCheck, reportIssue, ReportIssueRequestVariant } from '@breeztech/react-native-breez-sdk'
|
||||||
|
|
||||||
|
const healthCheckStatus = async () => {
|
||||||
|
// ANCHOR: health-check-status
|
||||||
|
const healthCheck = await serviceHealthCheck()
|
||||||
|
console.log(`Current service status is: ${healthCheck.status}`)
|
||||||
|
// ANCHOR_END: health-check-status
|
||||||
|
}
|
||||||
|
|
||||||
|
const reportPaymentFailure = async () => {
|
||||||
|
// ANCHOR: report-payment-failure
|
||||||
|
const paymentHash = "..."
|
||||||
|
await reportIssue({
|
||||||
|
type: ReportIssueRequestVariant.PAYMENT_FAILURE,
|
||||||
|
data: { paymentHash }
|
||||||
|
})
|
||||||
|
// ANCHOR_END: report-payment-failure
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ mod receive_payment;
|
|||||||
mod send_onchain;
|
mod send_onchain;
|
||||||
mod send_payment;
|
mod send_payment;
|
||||||
mod send_spontaneous_payment;
|
mod send_spontaneous_payment;
|
||||||
|
mod service_status;
|
||||||
mod static_channel_backup;
|
mod static_channel_backup;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|||||||
30
snippets/rust/src/service_status.rs
Normal file
30
snippets/rust/src/service_status.rs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
use breez_sdk_core::*;
|
||||||
|
use log::info;
|
||||||
|
|
||||||
|
async fn health_check_status(sdk: Arc<BreezServices>) -> Result<()> {
|
||||||
|
// ANCHOR: health-check-status
|
||||||
|
let health_check = sdk.service_health_check().await?;
|
||||||
|
info!("Current service status is: {:?}", health_check.status);
|
||||||
|
// ANCHOR_END: health-check-status
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn report_payment_failure(sdk: Arc<BreezServices>) -> Result<()> {
|
||||||
|
// ANCHOR: report-payment-failure
|
||||||
|
let payment_hash = String::from("...");
|
||||||
|
|
||||||
|
sdk.report_issue(ReportIssueRequest::PaymentFailure {
|
||||||
|
data: ReportPaymentFailureDetails {
|
||||||
|
payment_hash,
|
||||||
|
comment: None,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
// ANCHOR_END: report-payment-failure
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
27
snippets/swift/BreezSDKExamples/Sources/ServiceStatus.swift
Normal file
27
snippets/swift/BreezSDKExamples/Sources/ServiceStatus.swift
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// ServiceStatus.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by dangeross on 27/11/2023.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import BreezSDK
|
||||||
|
|
||||||
|
func getServiceStatus(sdk: BlockingBreezServices) -> ServiceHealthCheckResponse? {
|
||||||
|
// ANCHOR: health-check-status
|
||||||
|
let healthCheck = try? sdk.serviceHealthCheck()
|
||||||
|
print("Current service status is: \(healthCheck?.status)")
|
||||||
|
// ANCHOR_END: health-check-status
|
||||||
|
return healthCheck
|
||||||
|
}
|
||||||
|
|
||||||
|
func reportPaymentFailure(sdk: BlockingBreezServices) {
|
||||||
|
// ANCHOR: report-payment-failure
|
||||||
|
let paymentHash = "..."
|
||||||
|
|
||||||
|
try? sdk.reportIssue(
|
||||||
|
req: ReportIssueRequest.paymentFailure(
|
||||||
|
data: ReportPaymentFailureDetails(paymentHash: paymentHash)))
|
||||||
|
// ANCHOR_END: report-payment-failure
|
||||||
|
}
|
||||||
@@ -20,4 +20,5 @@
|
|||||||
- [Supporting fiat currencies](guide/fiat_currencies.md)
|
- [Supporting fiat currencies](guide/fiat_currencies.md)
|
||||||
- [Buy Bitcoin](guide/buy_btc.md)
|
- [Buy Bitcoin](guide/buy_btc.md)
|
||||||
- [Static Channel Backup](guide/static_channel_backup.md)
|
- [Static Channel Backup](guide/static_channel_backup.md)
|
||||||
|
- [Service status](guide/service_status.md)
|
||||||
- [Moving to production](guide/production.md)
|
- [Moving to production](guide/production.md)
|
||||||
|
|||||||
140
src/guide/service_status.md
Normal file
140
src/guide/service_status.md
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
# Health Check Status
|
||||||
|
|
||||||
|
You can check the general health status of the services providered by the Breez SDK.
|
||||||
|
The response status will inform you if there is maintenance occurring, a service distruption or the services are operational.
|
||||||
|
|
||||||
|
<custom-tabs category="lang">
|
||||||
|
<div slot="title">Rust</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```rust,ignore
|
||||||
|
{{#include ../../snippets/rust/src/service_status.rs:health-check-status}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Swift</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```swift,ignore
|
||||||
|
{{#include ../../snippets/swift/BreezSDKExamples/Sources/ServiceStatus.swift:health-check-status}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Kotlin</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```kotlin,ignore
|
||||||
|
{{#include ../../snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ServiceStatus.kt:health-check-status}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">React Native</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
{{#include ../../snippets/react-native/service_status.ts:health-check-status}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Dart</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```dart,ignore
|
||||||
|
{{#include ../../snippets/dart_snippets/lib/service_status.dart:health-check-status}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Python</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```python,ignore
|
||||||
|
{{#include ../../snippets/python/src/service_status.py:health-check-status}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Go</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```go,ignore
|
||||||
|
{{#include ../../snippets/go/service_status.go:health-check-status}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">C#</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```cs,ignore
|
||||||
|
{{#include ../../snippets/csharp/ServiceStatus.cs:health-check-status}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
</custom-tabs>
|
||||||
|
|
||||||
|
# Reporting a Payment Failure
|
||||||
|
|
||||||
|
While attempting to send payments it may be that sometimes payment failures occur. Reporting these issues through the Breez SDK will help us to improve LSP routing.
|
||||||
|
|
||||||
|
<custom-tabs category="lang">
|
||||||
|
<div slot="title">Rust</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```rust,ignore
|
||||||
|
{{#include ../../snippets/rust/src/service_status.rs:report-payment-failure}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Swift</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```swift,ignore
|
||||||
|
{{#include ../../snippets/swift/BreezSDKExamples/Sources/ServiceStatus.swift:report-payment-failure}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Kotlin</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```kotlin,ignore
|
||||||
|
{{#include ../../snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ServiceStatus.kt:report-payment-failure}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">React Native</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
{{#include ../../snippets/react-native/service_status.ts:report-payment-failure}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Dart</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```dart,ignore
|
||||||
|
{{#include ../../snippets/dart_snippets/lib/service_status.dart:report-payment-failure}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Python</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```python,ignore
|
||||||
|
{{#include ../../snippets/python/src/service_status.py:report-payment-failure}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Go</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```go,ignore
|
||||||
|
{{#include ../../snippets/go/service_status.go:report-payment-failure}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">C#</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```cs,ignore
|
||||||
|
{{#include ../../snippets/csharp/ServiceStatus.cs:report-payment-failure}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
</custom-tabs>
|
||||||
Reference in New Issue
Block a user