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_payment;
|
||||
mod send_spontaneous_payment;
|
||||
mod service_status;
|
||||
mod static_channel_backup;
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user