46 lines
950 B
Go
46 lines
950 B
Go
|
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
|
||
|
Status ResourceStatus
|
||
|
Pinned bool
|
||
|
LastChecked time.Time
|
||
|
|
||
|
// only set if Status == ResourceStatusError
|
||
|
ErrorString string
|
||
|
|
||
|
// Indicate the URLs of resources which link to/are linked from this
|
||
|
// resource.
|
||
|
IncomingLinkURLs, OutgoingLinkURLs []URL
|
||
|
}
|