instance updates, including:
* permdisable instance on 6 failures * restore in proper state on db load
This commit is contained in:
		
							parent
							
								
									8dbd92abbd
								
							
						
					
					
						commit
						3d98a37374
					
				@ -62,6 +62,10 @@ func New(options ...func(i *Instance)) *Instance {
 | 
			
		||||
		opt(i)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if i.InitialFSMState == "FETCHING" {
 | 
			
		||||
		i.InitialFSMState = "READY_FOR_TOOTFETCH"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	i.FSM = fsm.NewFSM(
 | 
			
		||||
		i.InitialFSMState,
 | 
			
		||||
		fsm.Events{
 | 
			
		||||
@ -75,11 +79,13 @@ func New(options ...func(i *Instance)) *Instance {
 | 
			
		||||
			{Name: "EARLY_FETCH_ERROR", Src: []string{"FETCHING_NODEINFO_URL", "PRE_NODEINFO_FETCH", "FETCHING_NODEINFO"}, Dst: "EARLY_ERROR"},
 | 
			
		||||
			{Name: "TOOT_FETCH_ERROR", Src: []string{"FETCHING"}, Dst: "TOOT_FETCH_ERROR"},
 | 
			
		||||
			{Name: "TOOTS_FETCHED", Src: []string{"FETCHING"}, Dst: "READY_FOR_TOOTFETCH"},
 | 
			
		||||
			{Name: "DISABLEMENT", Src: []string{"WEIRD_NODE", "EARLY_ERROR", "TOOT_FETCH_ERROR"}, Dst: "DISABLED"},
 | 
			
		||||
		},
 | 
			
		||||
		fsm.Callbacks{
 | 
			
		||||
			"enter_state": func(e *fsm.Event) { i.fsmEnterState(e) },
 | 
			
		||||
		},
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	return i
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -125,8 +131,18 @@ func (i *Instance) Unlock() {
 | 
			
		||||
func (i *Instance) bumpFetchError() {
 | 
			
		||||
	i.Lock()
 | 
			
		||||
	probablyDead := i.ConsecutiveErrorCount > 3
 | 
			
		||||
	shouldDisable := i.ConsecutiveErrorCount > 6
 | 
			
		||||
	i.Unlock()
 | 
			
		||||
 | 
			
		||||
	if shouldDisable {
 | 
			
		||||
		// auf wiedersehen, felicia
 | 
			
		||||
		i.Lock()
 | 
			
		||||
		i.Disabled = true
 | 
			
		||||
		i.Unlock()
 | 
			
		||||
		i.Event("DISABLEMENT")
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if probablyDead {
 | 
			
		||||
		// if three consecutive fetch errors happen, only try once per day:
 | 
			
		||||
		i.setNextFetchAfter(instancePersistentErrorInterval)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user