removed some cruft
This commit is contained in:
parent
a54c241970
commit
5807616992
@ -12,9 +12,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var p *bluemonday.Policy
|
||||||
|
|
||||||
func PollMastodonPleroma(endpoint string, reportPostChan chan ReportPost) {
|
func PollMastodonPleroma(endpoint string, reportPostChan chan ReportPost) {
|
||||||
// Make this a global variable
|
// Make this a global variable
|
||||||
p := bluemonday.NewPolicy()
|
//p := bluemonday.NewPolicy()
|
||||||
newposts := make([]ReportPost, 0)
|
newposts := make([]ReportPost, 0)
|
||||||
|
|
||||||
min_id := ""
|
min_id := ""
|
||||||
|
41
poll/main.go
41
poll/main.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/microcosm-cc/bluemonday"
|
||||||
"github.com/jackc/pgx/pgxpool"
|
"github.com/jackc/pgx/pgxpool"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -21,12 +22,7 @@ func AppendIfMissing(hay []string, needle string) []string {
|
|||||||
return append(hay, needle)
|
return append(hay, needle)
|
||||||
}
|
}
|
||||||
|
|
||||||
func imdone() {
|
|
||||||
// fmt.Println("I am done")
|
|
||||||
}
|
|
||||||
|
|
||||||
func writePost(pool *pgxpool.Pool, reportpost ReportPost) {
|
func writePost(pool *pgxpool.Pool, reportpost ReportPost) {
|
||||||
defer imdone()
|
|
||||||
conn, err := pool.Acquire(context.Background())
|
conn, err := pool.Acquire(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Error connecting to database:", err)
|
log.Fatal("Error connecting to database:", err)
|
||||||
@ -77,6 +73,7 @@ var runninginstances map[string]RunningInstance
|
|||||||
var ri_mutex = &sync.Mutex{}
|
var ri_mutex = &sync.Mutex{}
|
||||||
|
|
||||||
func engine() {
|
func engine() {
|
||||||
|
p = bluemonday.NewPolicy()
|
||||||
runninginstances = make(map[string]RunningInstance)
|
runninginstances = make(map[string]RunningInstance)
|
||||||
|
|
||||||
// Initial Setup
|
// Initial Setup
|
||||||
@ -94,7 +91,7 @@ func engine() {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// defer l.Close()
|
defer l.Close()
|
||||||
|
|
||||||
commandClient := make(chan net.Conn)
|
commandClient := make(chan net.Conn)
|
||||||
|
|
||||||
@ -104,21 +101,11 @@ func engine() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error on accept", err)
|
fmt.Println("Error on accept", err)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
// commandClient <- nil
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
commandClient <- c
|
commandClient <- c
|
||||||
}
|
}
|
||||||
}(l)
|
}(l)
|
||||||
|
|
||||||
go func() {
|
|
||||||
for{
|
|
||||||
v := <-reportPostChan // New Post
|
|
||||||
// fmt.Println(v)
|
|
||||||
go writePost(pool, v)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
c := <-commandClient // New client connection
|
c := <-commandClient // New client connection
|
||||||
@ -126,29 +113,11 @@ func engine() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
/*
|
|
||||||
for {
|
for {
|
||||||
select {
|
v := <-reportPostChan // New Post
|
||||||
case w := <-instanceReportChan: // Start or suspend instance
|
go writePost(pool, v)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
go engine()
|
go engine()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user