Browse Source

Queue page V1 OK.

Frédéric G. MARAND 2 years ago
parent
commit
e24e4cf385
2 changed files with 55 additions and 19 deletions
  1. 4 0
      back/web/routes.go
  2. 51 19
      front/templates/queue.gohtml

+ 4 - 0
back/web/routes.go

@@ -6,6 +6,7 @@ import (
 	"html/template"
 	"net/http"
 	"path/filepath"
+	"time"
 
 	"github.com/Masterminds/sprig/v3"
 	"github.com/davecgh/go-spew/spew"
@@ -68,6 +69,9 @@ func RendererService(_ *izidic.Container) (any, error) {
 		"dump": func(args ...any) template.HTML {
 			return "<pre>" + template.HTML(spew.Sdump(args...)) + "</pre>\n"
 		},
+		"timestamp": func(ts int64) time.Time {
+			return time.Unix(ts, 0)
+		},
 	}).Funcs(sprig.FuncMap())
 	for _, tpl := range []struct {
 		name  string

+ 51 - 19
front/templates/queue.gohtml

@@ -19,36 +19,68 @@
             <h1 class="text-3xl font-bold underline">Queue view for {{ .info.Name }}</h1>
             {{ template "flashes" .flashes }}
             <div class="alert alert-secondary alert-dismissible fade show row">
-                <div class="col col-2">Délai SQS info</div>
+                <div class="col col-2">SQS info latency</div>
                 <div class="col col-4">{{ .latency.info }}</div>
-                <div class="col col-2">Délai SQS messages</div>
+                <div class="col col-2">SQS messages latency</div>
                 <div class="col col-4">{{ .latency.items }}</div>
                 <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
             </div>
+            {{ $timeFormat := "2006-01-02 03:04:05 -0700" }}
             <table class="table">
                 <thead>
-                <tr>
-                    <th scope="col">Propriété</th>
-                    <th scope="col">Propriété</th>
-                    <th scope="col">Valeur</th>
-                </tr>
                 </thead>
                 <tbody>
+                {{ $attr := .info.Attributes }}
                 <tr>
-                    <th scope="row">Nom</th>
-                    <td>{{ .info.Name }}
-                    </td>
+                    <th scope="row">Info</th>
+                    <td>Link: <a href="{{ .info.URL }}">{{ .info.Name }}</a></td>
+                    <td>ARN: {{ $attr.QueueARN }}</td>
                 </tr>
                 <tr>
-                    <th scope="row">URL</th>
-                    <td><a href="{{ .info.URL }}">{{ .info.URL }}</a>
-                    </td>
+                    <th scope="row">Times</th>
+                    <td>Created: {{ timestamp $attr.CreatedTimestamp }}</td>
+                    <td>Last modified: {{ timestamp $attr.LastModifiedTimestamp }}</td>
                 </tr>
                 <tr>
-                    <th scope="row">Info</th>
-                    <td>{{ dump .info }}</td>
-
+                    <th scope="row" rowspan="2">Durations</th>
+                    <td>Queue delay: {{ $attr.DelaySeconds }} seconds</td>
+                    <td>Visibility Timeout: {{ $attr.VisibilityTimeout }} seconds</td>
+                </tr>
+                <tr>
+                    <td>Retention period: {{ $attr.MessageRetentionPeriod }} seconds</td>
+                    <td>Receive wait time: {{ $attr.ReceiveMessageWaitTimeSeconds }} seconds</td>
+                </tr>
+                <tr>
+                    <th scope="row">Counts</th>
+                    <td>Approx. messages: {{ $attr.ApproximateNumberOfMessages }}</td>
+                    <td>Approx. delayed: {{ $attr.ApproximateNumberOfMessagesDelayed }}</td>
+                </tr>
+                <tr>
+                    <th scope="row">Messages</th>
+                    <td>Approx. not visible: {{ $attr.ApproximateNumberOfMessagesNotVisible }}</td>
+                    <td>Max. size: {{ $attr.MaximumMessageSize }}</td>
                 </tr>
+                {{ if $attr.RedrivePolicy }}
+                    <tr>
+                        <th scope="row">DeadLetter queue</th>
+                        <td>ARN: {{ $attr.RedrivePolicy.DeadLetterTargetARN }}</td>
+                        <td>Max. receive count: {{ $attr.RedrivePolicy.MaxReceiveCount }}</td>
+                    </tr>
+                {{ end }}
+                {{ if $attr.RedriveAllowPolicy }}
+                    <tr>
+                        <th scope="row">Source queues for DLQ</th>
+                        <td>Redrive Permission: {{ $attr.RedriveAllowPolicy.RedrivePermission }}</td>
+                        <td>Queues:
+                            <ul>
+                                {{ range $attr.RedriveAllowPolicy.SourceQueueARNs }}
+                                    <li>{{ . }}</li>
+                                {{ end }}
+                            </ul>
+                        </td>
+
+                    </tr>
+                {{ end }}
                 </tbody>
             </table>
         </div>
@@ -95,9 +127,9 @@
 
 {{ define "queue-item" -}}
     <tr>
-        <th scope="row"><input class="form-check-input checkbox" type="checkbox" name="id-{{ .i }}" />
-        <input type="hidden" name="rh-{{ .i }}" value="{{ .message.ReceiptHandle }}" /></th>
-        <input type="hidden" name="mid-{{ .i }}" value="{{ .message.MessageId }}" /></th>
+        <th scope="row"><input class="form-check-input checkbox" type="checkbox" name="id-{{ .i }}"/>
+            <input type="hidden" name="rh-{{ .i }}" value="{{ .message.ReceiptHandle }}"/></th>
+        <input type="hidden" name="mid-{{ .i }}" value="{{ .message.MessageId }}"/></th>
         <td>{{ .message.MessageId }}</td>
         <td>{{ abbrev 80 .message.Body }}</td>
         <td>{{ toJson .message.MessageAttributes | abbrev 80 }}</td>