deadlinks/resource.go

47 lines
1.1 KiB
Go
Raw Normal View History

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"`
// only set if Status == ResourceStatusError
2023-12-30 11:17:36 +00:00
ErrorString string `yaml:"error"`
// 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"`
}