summaryrefslogtreecommitdiff
path: root/internal/server
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-09-18 01:04:26 +0300
committerPaul Buetow <paul@buetow.org>2024-09-18 01:04:26 +0300
commit5263e61d5667009e7a7ac13014cec73ccbd0e20a (patch)
tree64187b679f0b0da34840c3d77d5bde441cea3fb0 /internal/server
parent279ee9e1026f74f923766286b767d4df3901b82f (diff)
some stuff
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/cron/cron.go4
-rw-r--r--internal/server/repository/pending.go9
-rw-r--r--internal/server/repository/repository.go5
-rw-r--r--internal/server/scheduler/scheduler.go15
4 files changed, 27 insertions, 6 deletions
diff --git a/internal/server/cron/cron.go b/internal/server/cron/cron.go
index 3de44b8..3d6b9cf 100644
--- a/internal/server/cron/cron.go
+++ b/internal/server/cron/cron.go
@@ -28,7 +28,9 @@ func Run(ctx context.Context, conf config.ServerConfig, status health.Status) {
case <-mergeTicker.C:
run(ctx, "cron->repository.Merge", status, repository.Instance(conf).MergeRemotely)
case <-scheduleTicker.C:
- run(ctx, "cron->scheduler.Run", status, scheduler.Run)
+ run(ctx, "cron->scheduler.Run", status, func(ctx context.Context) error {
+ return scheduler.Run(ctx, conf)
+ })
}
}
}
diff --git a/internal/server/repository/pending.go b/internal/server/repository/pending.go
index 2245f30..a1fd7a7 100644
--- a/internal/server/repository/pending.go
+++ b/internal/server/repository/pending.go
@@ -13,6 +13,15 @@ func newPending() pending {
return pending{make(map[types.PlatformName]pendingEntries)}
}
+// Returns number of pending entries for the platform
+// func (p pending) num(platform types.PlatformName) int {
+// pe, ok := p.platforms[platform]
+// if !ok {
+// return 0
+// }
+// return len(pe)
+// }
+
func (p pending) add(platform types.PlatformName, id types.EntryID) {
pe, ok := p.platforms[platform]
if !ok {
diff --git a/internal/server/repository/repository.go b/internal/server/repository/repository.go
index 77f23ec..d277884 100644
--- a/internal/server/repository/repository.go
+++ b/internal/server/repository/repository.go
@@ -33,8 +33,10 @@ type entryPair struct {
}
// Holds all entries in the database / stores them to the disks..
+// TODO: Keep track of how many posts were made this week already.
type Repository struct {
- pending
+ pending pending
+ stats stats
conf server.ServerConfig
entries map[types.EntryID]types.Entry
mu *sync.Mutex
@@ -55,6 +57,7 @@ func newRepository(conf server.ServerConfig, fs fs) Repository {
var loaded bool
return Repository{
pending: newPending(), // TODO: Make use of the pending for the selection algoritmh for the next post
+ stats: newStats(), // TODO: Make use of this.
conf: conf,
entries: make(map[types.EntryID]types.Entry),
mu: &sync.Mutex{},
diff --git a/internal/server/scheduler/scheduler.go b/internal/server/scheduler/scheduler.go
index da66519..bbcb59a 100644
--- a/internal/server/scheduler/scheduler.go
+++ b/internal/server/scheduler/scheduler.go
@@ -1,9 +1,16 @@
package scheduler
-import "context"
+import (
+ "context"
+ "log"
-// TODO: Implement this
-func Run(ctx context.Context) error {
- // Need to figure out which posts to post where.
+ "codeberg.org/snonux/gos/internal/config/server"
+)
+
+// TODO: Finish implementing this
+func Run(ctx context.Context, config server.ServerConfig) error {
+ for _, platform := range config.SocialPlatformsEnabled {
+ log.Println("TODO: implement ... posting a post now or what on", platform)
+ }
return nil
}