removed some cruft

This commit is contained in:
farhan 2020-11-17 22:35:59 -05:00
parent a54c241970
commit 5807616992
2 changed files with 8 additions and 37 deletions

View File

@ -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 := ""

View File

@ -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,29 +113,11 @@ 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")
v := <-reportPostChan // New Post
go writePost(pool, v)
}
}
go DeferPollRun(w, instanceReportChan, reportPostChan)
} else {
SuspendInstance(w)
}
}
}
*/
}
func main() {
go engine()