From 5807616992a2ffca9cce4bd8265cd446c266e7bf Mon Sep 17 00:00:00 2001 From: Farhan Khan Date: Tue, 17 Nov 2020 22:35:59 -0500 Subject: [PATCH] removed some cruft --- poll/instance.go | 4 +++- poll/main.go | 41 +++++------------------------------------ 2 files changed, 8 insertions(+), 37 deletions(-) diff --git a/poll/instance.go b/poll/instance.go index 83b84d5..706e92e 100644 --- a/poll/instance.go +++ b/poll/instance.go @@ -12,9 +12,11 @@ import ( "fmt" ) +var p *bluemonday.Policy + func PollMastodonPleroma(endpoint string, reportPostChan chan ReportPost) { // Make this a global variable - p := bluemonday.NewPolicy() + //p := bluemonday.NewPolicy() newposts := make([]ReportPost, 0) min_id := "" diff --git a/poll/main.go b/poll/main.go index 0c0ce9f..18e8624 100644 --- a/poll/main.go +++ b/poll/main.go @@ -1,6 +1,7 @@ package main import ( + "github.com/microcosm-cc/bluemonday" "github.com/jackc/pgx/pgxpool" _ "net/http/pprof" "net/http" @@ -21,12 +22,7 @@ func AppendIfMissing(hay []string, needle string) []string { return append(hay, needle) } -func imdone() { - // fmt.Println("I am done") -} - func writePost(pool *pgxpool.Pool, reportpost ReportPost) { - defer imdone() conn, err := pool.Acquire(context.Background()) if err != nil { log.Fatal("Error connecting to database:", err) @@ -77,6 +73,7 @@ var runninginstances map[string]RunningInstance var ri_mutex = &sync.Mutex{} func engine() { + p = bluemonday.NewPolicy() runninginstances = make(map[string]RunningInstance) // Initial Setup @@ -94,7 +91,7 @@ func engine() { fmt.Println(err) return } -// defer l.Close() + defer l.Close() commandClient := make(chan net.Conn) @@ -104,21 +101,11 @@ func engine() { if err != nil { fmt.Println("Error on accept", err) os.Exit(0) -// commandClient <- nil - return } commandClient <- c } }(l) - go func() { - for{ - v := <-reportPostChan // New Post -// fmt.Println(v) - go writePost(pool, v) - } - }() - go func() { for { c := <-commandClient // New client connection @@ -126,28 +113,10 @@ func engine() { } }() -/* for { - select { - case w := <-instanceReportChan: // Start or suspend instance - if w.status == NEW_INSTANCE { - x = x + 1 - NewInstance(w.endpoint, instanceReportChan, reportPostChan) - } else if w.status == RUNNING || w.status == TOOMANYREQUESTS { - for i, runninginstance := range runninginstances { - if runninginstance.Endpoint == w.endpoint { - runninginstances[i].Min_id = w.min_id - runninginstances[i].Status = w.status - runninginstances[i].LastRun = time.Now().Format("2006.01.02-15:04:05") - } - } - go DeferPollRun(w, instanceReportChan, reportPostChan) - } else { - SuspendInstance(w) - } - } + v := <-reportPostChan // New Post + go writePost(pool, v) } -*/ } func main() {