mirror of
https://github.com/mii443/prometheus-android-exporter.git
synced 2025-08-22 15:15:35 +00:00
staging
This commit is contained in:
@ -178,20 +178,22 @@ class PushProxClient(
|
|||||||
while (shouldContinue) {
|
while (shouldContinue) {
|
||||||
log("pushprox main loop", "loop start")
|
log("pushprox main loop", "loop start")
|
||||||
// register poll error using try-catch block
|
// register poll error using try-catch block
|
||||||
try {
|
var result = context.backoff.withRetries {
|
||||||
doPoll(context)
|
try {
|
||||||
}catch(e : CancellationException){
|
doPoll(context)
|
||||||
shouldContinue = false
|
}catch(e : CancellationException){
|
||||||
}
|
shouldContinue = false
|
||||||
catch (e: Exception) {
|
}
|
||||||
for(exception in e.suppressed){
|
catch (e: Exception) {
|
||||||
if(exception is CancellationException){
|
for(exception in e.suppressed){
|
||||||
shouldContinue = false
|
if(exception is CancellationException){
|
||||||
}
|
shouldContinue = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log("exception encountered!", e.toString())
|
||||||
|
counters.pollError()
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
log("exception encountered!", e.toString())
|
|
||||||
counters.pollError()
|
|
||||||
throw e
|
|
||||||
}
|
}
|
||||||
log("pushprox main loop", "loop end")
|
log("pushprox main loop", "loop end")
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.birdthedeveloper.prometheus.android.prometheus.android.exporter
|
package com.birdthedeveloper.prometheus.android.prometheus.android.exporter
|
||||||
|
|
||||||
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
@ -20,12 +21,18 @@ class PushProxWorker(
|
|||||||
parameters : WorkerParameters
|
parameters : WorkerParameters
|
||||||
): CoroutineWorker(context, parameters){
|
): CoroutineWorker(context, parameters){
|
||||||
|
|
||||||
|
private val notificationManager =
|
||||||
|
context.getSystemService(Context.NOTIFICATION_SERVICE) as
|
||||||
|
NotificationManager
|
||||||
|
|
||||||
override suspend fun doWork():Result {
|
override suspend fun doWork():Result {
|
||||||
//TODO implement this
|
//TODO implement this
|
||||||
val cache: PushProxWorkerCache = PushProxWorkerCache.getInstance {
|
val cache: PushProxWorkerCache = PushProxWorkerCache.getInstance {
|
||||||
return@getInstance context
|
return@getInstance context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setForeground(createForegroundInfo())
|
||||||
|
|
||||||
try{
|
try{
|
||||||
val pushProxConfig : PushProxConfig = PushProxConfig.fromData(inputData)
|
val pushProxConfig : PushProxConfig = PushProxConfig.fromData(inputData)
|
||||||
|
|
||||||
@ -38,6 +45,29 @@ class PushProxWorker(
|
|||||||
|
|
||||||
return Result.success()
|
return Result.success()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun createForegroundInfo(): ForegroundInfo {
|
||||||
|
val id = "channel_id"
|
||||||
|
val title = "title"
|
||||||
|
val cancel = "cancel_download"
|
||||||
|
// This PendingIntent can be used to cancel the worker
|
||||||
|
val intent = WorkManager.getInstance(applicationContext)
|
||||||
|
.createCancelPendingIntent(getId())
|
||||||
|
|
||||||
|
val notification = NotificationCompat.Builder(applicationContext, id)
|
||||||
|
.setContentTitle(title)
|
||||||
|
.setTicker(title)
|
||||||
|
.setContentText("progress")
|
||||||
|
.setSmallIcon(R.drawable.ic_launcher_foreground)
|
||||||
|
.setOngoing(true)
|
||||||
|
// Add the cancel action to the notification which can
|
||||||
|
// be used to cancel the worker
|
||||||
|
.addAction(android.R.drawable.ic_delete, cancel, intent)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
return ForegroundInfo(notificationId, notification)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// thread-safe singleton
|
// thread-safe singleton
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Prometheus global configuration file
|
# Prometheus global configuration file
|
||||||
global:
|
global:
|
||||||
scrape_interval: 5s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
|
scrape_interval: 3s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
|
||||||
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
|
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
|
||||||
scrape_configs:
|
scrape_configs:
|
||||||
- job_name: "prometheus"
|
- job_name: "prometheus"
|
||||||
|
Reference in New Issue
Block a user