builds again
This commit is contained in:
@@ -28,10 +28,6 @@ const instanceErrorInterval = time.Second * 60 * 30
|
||||
|
||||
type instanceImplementation int
|
||||
|
||||
// Hostname is a special type for holding the hostname of an
|
||||
// instance (string)
|
||||
type Hostname string
|
||||
|
||||
const (
|
||||
implUnknown instanceImplementation = iota
|
||||
implMastodon
|
||||
@@ -40,34 +36,35 @@ const (
|
||||
|
||||
// Instance stores all the information we know about an instance
|
||||
type Instance struct {
|
||||
Identifier uuid.UUID
|
||||
Disabled bool
|
||||
ErrorCount uint
|
||||
FSM *fsm.FSM
|
||||
Fetching bool
|
||||
HighestID uint
|
||||
Hostname string
|
||||
UUID uuid.UUID
|
||||
Identified bool
|
||||
Implementation instanceImplementation
|
||||
NextFetch time.Time
|
||||
NodeInfoURL string
|
||||
ServerImplementationString string
|
||||
ServerVersionString string
|
||||
SuccessCount uint
|
||||
fetchingLock sync.Mutex
|
||||
fsmLock sync.Mutex
|
||||
storageBackend *storage.TootStorageBackend
|
||||
structLock sync.Mutex
|
||||
tootDestination chan *toot.Toot
|
||||
ErrorCount uint
|
||||
SuccessCount uint
|
||||
highestID int
|
||||
Hostname string
|
||||
Identified bool
|
||||
fetching bool
|
||||
disabled bool
|
||||
implementation instanceImplementation
|
||||
storageBackend *storage.TootStorageBackend
|
||||
NextFetch time.Time
|
||||
nodeInfoURL string
|
||||
ServerVersionString string
|
||||
ServerImplementationString string
|
||||
fetchingLock sync.Mutex
|
||||
fsm *fsm.FSM
|
||||
fsmLock sync.Mutex
|
||||
}
|
||||
|
||||
// New returns a new instance, argument is a function that operates on the
|
||||
// new instance
|
||||
func New(options ...func(i *Instance)) *Instance {
|
||||
i := new(Instance)
|
||||
i.UUID = uuid.New()
|
||||
i.setNextFetchAfter(1 * time.Second)
|
||||
|
||||
i.fsm = fsm.NewFSM(
|
||||
i.FSM = fsm.NewFSM(
|
||||
"STATUS_UNKNOWN",
|
||||
fsm.Events{
|
||||
{Name: "BEGIN_NODEINFO_URL_FETCH", Src: []string{"STATUS_UNKNOWN"}, Dst: "FETCHING_NODEINFO_URL"},
|
||||
@@ -96,7 +93,7 @@ func New(options ...func(i *Instance)) *Instance {
|
||||
func (i *Instance) Status() string {
|
||||
i.fsmLock.Lock()
|
||||
defer i.fsmLock.Unlock()
|
||||
return i.fsm.Current()
|
||||
return i.FSM.Current()
|
||||
}
|
||||
|
||||
// SetTootDestination takes a channel from the manager that all toots
|
||||
@@ -111,7 +108,7 @@ func (i *Instance) SetTootDestination(d chan *toot.Toot) {
|
||||
func (i *Instance) Event(eventname string) {
|
||||
i.fsmLock.Lock()
|
||||
defer i.fsmLock.Unlock()
|
||||
i.fsm.Event(eventname)
|
||||
i.FSM.Event(eventname)
|
||||
}
|
||||
|
||||
func (i *Instance) fsmEnterState(e *fsm.Event) {
|
||||
@@ -198,7 +195,7 @@ func (i *Instance) Tick() {
|
||||
func (i *Instance) nodeIdentified() bool {
|
||||
i.Lock()
|
||||
defer i.Unlock()
|
||||
if i.implementation > implUnknown {
|
||||
if i.Implementation > implUnknown {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -288,7 +285,7 @@ func (i *Instance) fetchNodeInfoURL() error {
|
||||
Msg("success fetching url for nodeinfo")
|
||||
|
||||
i.Lock()
|
||||
i.nodeInfoURL = item.Href
|
||||
i.NodeInfoURL = item.Href
|
||||
i.Unlock()
|
||||
i.registerSuccess()
|
||||
i.Event("GOT_NODEINFO_URL")
|
||||
@@ -323,7 +320,7 @@ func (i *Instance) fetchNodeInfo() error {
|
||||
//FIXME make sure the nodeinfourl is on the same domain as the instance
|
||||
//hostname
|
||||
i.Lock()
|
||||
url := i.nodeInfoURL
|
||||
url := i.NodeInfoURL
|
||||
i.Unlock()
|
||||
|
||||
i.Event("BEGIN_NODEINFO_FETCH")
|
||||
@@ -368,7 +365,7 @@ func (i *Instance) fetchNodeInfo() error {
|
||||
Str("serverVersion", ni.Software.Version).
|
||||
Str("software", ni.Software.Name).
|
||||
Str("hostname", i.Hostname).
|
||||
Str("nodeInfoURL", i.nodeInfoURL).
|
||||
Str("nodeInfoURL", i.NodeInfoURL).
|
||||
Msg("received nodeinfo from instance")
|
||||
|
||||
i.Lock()
|
||||
@@ -382,7 +379,7 @@ func (i *Instance) fetchNodeInfo() error {
|
||||
Str("software", ni.Software.Name).
|
||||
Msg("detected server software")
|
||||
i.Identified = true
|
||||
i.implementation = implPleroma
|
||||
i.Implementation = implPleroma
|
||||
i.Unlock()
|
||||
i.registerSuccess()
|
||||
i.Event("GOT_NODEINFO")
|
||||
@@ -393,7 +390,7 @@ func (i *Instance) fetchNodeInfo() error {
|
||||
Str("software", ni.Software.Name).
|
||||
Msg("detected server software")
|
||||
i.Identified = true
|
||||
i.implementation = implMastodon
|
||||
i.Implementation = implMastodon
|
||||
i.Unlock()
|
||||
i.registerSuccess()
|
||||
i.Event("GOT_NODEINFO")
|
||||
|
||||
Reference in New Issue
Block a user