This commit is contained in:
Jeffrey Paul 2019-10-24 05:14:36 -07:00
parent 31f5a83c96
commit f864469860
4 changed files with 58 additions and 22 deletions

26
archiver.go Normal file
View File

@ -0,0 +1,26 @@
package main
import (
"fmt"
"github.com/rs/zerolog/log"
"net/http"
"time"
//"github.com/bitly/go-simplejson"
)
type InstanceHostName string
type Archiver struct {
locator *InstanceLocator
instances map[InstanceHostName]*Instance
startup *time.Time
}
func NewArchiver() *Archiver {
a := new(Archiver)
return a
}
func (a *Archiver) Run() {
}

View File

@ -8,21 +8,12 @@ import (
//"github.com/bitly/go-simplejson" //"github.com/bitly/go-simplejson"
) )
const mastodonIndexUrl = "https://instances.social/list.json?q%5Busers%5D=&q%5Bsearch%5D=&strict=false"
const pleromaIndexUrl = "https://distsn.org/cgi-bin/distsn-pleroma-instances-api.cgi"
type InstanceLocator struct {
pleromaIndexLastRefresh *time.Time
mastodonIndexLastRefresh *time.Time
instances map[string]Instance
}
type ServerImplementation int type ServerImplementation int
const ( const (
Mastodon ServerImplementation = iota + 1 ServerUnknown ServerImplementation = iota
Pleorama ServerMastodon
ServerPleorama
) )
type Instance struct { type Instance struct {
@ -42,7 +33,7 @@ func NewInstance(hostname string) *Instance {
} }
func (i *Instance) detectNodeType() { func (i *Instance) detectNodeType() {
if i.impl == 0 { if i.impl > ServerUnknown {
return return
} }
} }

24
instancelocator.go Normal file
View File

@ -0,0 +1,24 @@
package main
import (
"fmt"
"github.com/rs/zerolog/log"
"net/http"
"time"
//"github.com/bitly/go-simplejson"
)
const mastodonIndexUrl = "https://instances.social/list.json?q%5Busers%5D=&q%5Bsearch%5D=&strict=false"
const pleromaIndexUrl = "https://distsn.org/cgi-bin/distsn-pleroma-instances-api.cgi"
type InstanceLocator struct {
pleromaIndexLastRefresh *time.Time
mastodonIndexLastRefresh *time.Time
instances map[string]Instance
}
func NewInstanceLocator() *InstanceLocator {
i := new(InstanceLocator)
return i
}

13
main.go
View File

@ -18,11 +18,12 @@ func main() {
} }
func identify() { func identify() {
log.Debug(). log.Info().
Str("version", Version). Str("version", Version).
Str("buildarch", Buildarch). Str("buildarch", Buildarch).
Str("buildtime", Buildtime). Str("buildtime", Buildtime).
Str("builduser", Builduser).Send() Str("builduser", Builduser).Send().
Msg("starting")
} }
func app() int { func app() int {
@ -35,16 +36,10 @@ func app() int {
identify() identify()
log.Print("hello world")
// Default level for this example is info, unless debug flag is present
zerolog.SetGlobalLevel(zerolog.InfoLevel) zerolog.SetGlobalLevel(zerolog.InfoLevel)
if *debug { if *debug {
zerolog.SetGlobalLevel(zerolog.DebugLevel) zerolog.SetGlobalLevel(zerolog.DebugLevel)
} }
log.Debug().Msg("This message appears only when log level set to Debug") return NewArchiver().Run()
log.Info().Msg("This message appears when log level set to Debug or Info")
return 0
} }