aboutsummaryrefslogtreecommitdiff
path: root/internal/lume
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2023-10-02 15:07:26 -0400
committerXe Iaso <me@xeiaso.net>2023-10-02 15:07:26 -0400
commit21a3c8b3d0f500f5d2ff2d97e74897975ff9a39e (patch)
tree78bbc5d692622740c2a1a3167b9940645e425920 /internal/lume
parent6f8f5c8d7169c31bb379124bf488b89556469745 (diff)
downloadxesite-21a3c8b3d0f500f5d2ff2d97e74897975ff9a39e.tar.xz
xesite-21a3c8b3d0f500f5d2ff2d97e74897975ff9a39e.zip
cmd/xesite: add mi poking when builds are done
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'internal/lume')
-rw-r--r--internal/lume/lume.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/lume/lume.go b/internal/lume/lume.go
index b22e7d6..294f42c 100644
--- a/internal/lume/lume.go
+++ b/internal/lume/lume.go
@@ -19,6 +19,7 @@ import (
"gopkg.in/mxpv/patreon-go.v1"
"tailscale.com/metrics"
"xeiaso.net/v4/internal/config"
+ "xeiaso.net/v4/internal/mi"
)
var (
@@ -67,6 +68,8 @@ type FS struct {
opt *Options
conf *config.Config
+ miClient *mi.Client
+
fs fs.FS
lock sync.RWMutex
}
@@ -119,6 +122,7 @@ type Options struct {
URL string
PatreonClient *patreon.Client
DataDir string
+ MiToken string
}
func New(ctx context.Context, o *Options) (*FS, error) {
@@ -154,6 +158,11 @@ func New(ctx context.Context, o *Options) (*FS, error) {
}
}
+ if o.MiToken != "" {
+ fs.miClient = mi.New(o.MiToken, "xeiaso.net/v4/internal/lume "+os.Args[0])
+ slog.Info("mi integration enabled")
+ }
+
conf, err := config.Load(filepath.Join(fs.repoDir, "config.dhall"))
if err != nil {
log.Fatal(err)
@@ -165,6 +174,14 @@ func New(ctx context.Context, o *Options) (*FS, error) {
return nil, err
}
+ if fs.miClient != nil {
+ go func() {
+ if err := fs.miClient.Refresh(); err != nil {
+ slog.Error("failed to refresh mi", "err", err)
+ }
+ }()
+ }
+
return fs, nil
}
@@ -217,6 +234,14 @@ func (f *FS) Update(ctx context.Context) error {
return err
}
+ if f.miClient != nil {
+ go func() {
+ if err := f.miClient.Refresh(); err != nil {
+ slog.Error("failed to refresh mi", "err", err)
+ }
+ }()
+ }
+
return nil
}