2023-12-29 16:09:49 +00:00
|
|
|
package deadlinks
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ResourceStatus describes what state a particular Resource is in.
|
|
|
|
type ResourceStatus int
|
|
|
|
|
|
|
|
// Enumeration of ResourceStatus values.
|
|
|
|
const (
|
|
|
|
ResourceStatusUnknown ResourceStatus = iota
|
|
|
|
ResourceStatusOK
|
|
|
|
ResourceStatusError
|
|
|
|
)
|
|
|
|
|
|
|
|
func (ds ResourceStatus) String() string {
|
|
|
|
switch ds {
|
|
|
|
case ResourceStatusUnknown:
|
|
|
|
return "UNKNOWN"
|
|
|
|
case ResourceStatusOK:
|
|
|
|
return "OK"
|
|
|
|
case ResourceStatusError:
|
|
|
|
return "ERROR"
|
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("unknown ResourceStatus: %#v", ds))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resource describes the current state of a resource, with the resource being
|
|
|
|
// uniquely identified by a URL.
|
|
|
|
type Resource struct {
|
|
|
|
URL URL
|
2023-12-30 11:17:36 +00:00
|
|
|
Status ResourceStatus `yaml:"-"`
|
|
|
|
Pinned bool `yaml:"-"`
|
|
|
|
LastChecked time.Time `yaml:"last_checked"`
|
2023-12-29 16:09:49 +00:00
|
|
|
|
|
|
|
// only set if Status == ResourceStatusError
|
2023-12-30 11:17:36 +00:00
|
|
|
ErrorString string `yaml:"error"`
|
2023-12-29 16:09:49 +00:00
|
|
|
|
|
|
|
// Indicate the URLs of resources which link to/are linked from this
|
|
|
|
// resource.
|
2023-12-30 11:17:36 +00:00
|
|
|
IncomingLinkURLs []URL `yaml:"incoming_links"`
|
|
|
|
OutgoingLinkURLs []URL `yaml:"outgoing_links"`
|
2023-12-29 16:09:49 +00:00
|
|
|
}
|