Documentation ¶
Index ¶
- Constants
- Variables
- func CursorTimeout(duration time.Duration) func(*Config) error
- func DatastorePrefix(prefix string) func(*Config) error
- func DefaultQueue(queue string) func(*Config) error
- func Host(host string) func(*Config) error
- func LeaseDuration(duration time.Duration) func(*Config) error
- func LeaseTimeout(duration time.Duration) func(*Config) error
- func LogVerbose(c *Config) error
- func NewServer(path string, options ...Option) (http.Handler, error)
- func Oversampling(factor int) func(*Config) error
- func RegisterJob(job JobSpec) error
- func Retries(retries int) func(*Config) error
- func Shards(shards int) func(*Config) error
- func TaskTimeout(duration time.Duration) func(*Config) error
- type Config
- type Counters
- type DeleteSupported
- type Direction
- type GetSupported
- type HeadSupported
- type JobEntity
- type JobLifecycle
- type JobOutput
- type JobSpec
- type NamespaceLifecycle
- type Option
- type PatchSupported
- type PostSupported
- type PutSupported
- type Query
- func (q *Query) Filter(filterStr string, value interface{}) *Query
- func (q *Query) GobDecode(b []byte) error
- func (q *Query) GobEncode() ([]byte, error)
- func (q *Query) KeysOnly() *Query
- func (q *Query) MarshalJSON() ([]byte, error)
- func (q *Query) Namespace(namespaces ...string) *Query
- func (q *Query) NamespaceAll() *Query
- func (q *Query) NamespaceEmpty() *Query
- func (q *Query) NamespaceNamed() *Query
- func (q *Query) String() string
- type ShardLifecycle
- type SliceLifecycle
Constants ¶
const (
// DefaultPath is a decent default path to mount the mapper mux on
DefaultPath = "/_ah/mapper/"
)
Variables ¶
var ( // ErrJobNotFound is returned when an unregistered // job is requested ErrJobNotFound = errors.New("job not found") )
Functions ¶
func CursorTimeout ¶
CursorTimeout sets how long a datastore cursor is allowed to run
func DatastorePrefix ¶
DatastorePrefix sets the prefix for mapper datastore collections
func DefaultQueue ¶
DefaultQueue sets the default taskqueue to use when scheduling mapper tasks
func LeaseDuration ¶
LeaseDuration sets how long a worker will hold a lock for
func LeaseTimeout ¶
LeaseTimeout sets how long before a lock will be considered timedout
func NewServer ¶
NewServer configures the server and returns the handler for mounting within the app so it can control the endpoint to use. The server is actually already created but we need to know what the path prefix is.
func Oversampling ¶
Oversampling sets the factor to use to even out sampling
func RegisterJob ¶
RegisterJob registers jobs so they can be initiated by name and so the Job struct can be registered with the gob serializer.
Types ¶
type Config ¶
type Config struct { // Path is the mount point for the server Path string // DatastorePrefix is added to the beginning of every mapreduce collection name DatastorePrefix string // DefaultQueue is the default queue to use for mapreduce tasks if not DefaultQueue string // Shards is the default number of shards to use Shards int // Oversampling is a factor to increase the number of scatter samples // and helps achieve more even shard distribution with 'clumpy' data // (clumpy is definitely a technical term) Oversampling int // LeaseDuration is how long a worker will hold a lock for LeaseDuration time.Duration // LeaseTimeout is the time considered to be a timeout LeaseTimeout time.Duration // TaskTimeout is the time to execute a task for. // For frontend instances the limit is 10 minutes TaskTimeout time.Duration // CursorTimeout is the time to use a cursor for before requerying // The default limit is 50 seconds CursorTimeout time.Duration // Retries is the maximum number of times to retry a failing task Retries int // LogVerbose controls verbose logging output LogVerbose bool // Host sets the host header on tasks (if set) Host string }
Config stores mapper configuration settings
type Counters ¶
Counters provides a simple map of name / values for mappers
func NewCounters ¶
func NewCounters() Counters
type DeleteSupported ¶
type DeleteSupported interface {
Delete(http.ResponseWriter, *http.Request, string) (int, interface{}, error)
}
DeleteSupported is the interface that provides the Delete method a resource must support to receive HTTP DELETEs.
type GetSupported ¶
type GetSupported interface {
Get(http.ResponseWriter, *http.Request, string) (int, interface{}, error)
}
GetSupported is the interface that provides the Get method a resource must support to receive HTTP GETs.
type HeadSupported ¶
type HeadSupported interface {
Head(http.ResponseWriter, *http.Request, string) (int, interface{}, error)
}
HeadSupported is the interface that provides the Head method a resource must support to receive HTTP HEADs.
type JobEntity ¶
type JobEntity interface {
Make() interface{}
}
JobEntity is the interface that a mapper job should implement if it wants to map directly over datastore entities. i.e. *not* use a KeysOnly query. Implementing this interface will cause a full entity query to be performed and the entity will be loaded into whatever this function returns which should be a named field within the job struct. It will be called once at the beginning of any slice processing and the field will not live beyond the slice lifetime.
type JobLifecycle ¶
type JobLifecycle interface { // JobStarted is called when a mapper job is started JobStarted(c context.Context, id string) // JobStarted is called when a mapper job is completed JobCompleted(c context.Context, id string) }
JobLifecycle is the interface that any mapper job struct can implement to be notified of job lifecycle events. Use this if you want to perform any actions at the beginning and / or end of a job.
type JobOutput ¶
JobOutput is the interface that a mapper job should implement if it wants to write file output. Files will be created for each slice and rolled up into shards and then namespaces
type JobSpec ¶
type JobSpec interface { // Query creates the datastore query spec to define the entities that the job // should process. It is called when a new job is being initiated and passed // the request in order to extract any parameters from it that may be required Query(r *http.Request) (*Query, error) Next(c context.Context, counters Counters, key *datastore.Key) error }
JobSpec is the interface use by the mapper to create the datastore query spec
func CreateJobInstance ¶
CreateJobInstance creates a new JobSpec instance from the given name
type NamespaceLifecycle ¶
type NamespaceLifecycle interface { // NamespaceStarted is called when a mapper job for an individual // namespace is started NamespaceStarted(c context.Context, id string, namespace string) // NamespaceStarted is called when a mapper job for an individual // namespace is completed NamespaceCompleted(c context.Context, id string, namespace string) }
NamespaceLifecycle is the interface that any mapper job struct can implement to be notified of namespace lifecycle events. Use this is you want to perform any actions at the beginning and / or end of processing for each namespace.
type PatchSupported ¶
type PatchSupported interface {
Patch(http.ResponseWriter, *http.Request, string) (int, interface{}, error)
}
PatchSupported is the interface that provides the Patch method a resource must support to receive HTTP PATCHs.
type PostSupported ¶
type PostSupported interface {
Post(http.ResponseWriter, *http.Request, string) (int, interface{}, error)
}
PostSupported is the interface that provides the Post method a resource must support to receive HTTP POSTs.
type PutSupported ¶
type PutSupported interface {
Put(http.ResponseWriter, *http.Request, string) (int, interface{}, error)
}
PutSupported is the interface that provides the Put method a resource must support to receive HTTP PUTs.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query is a gob encodable specification of a datastore query with only the mapper supported query features provided and the addition ability to specify namespaces
func (*Query) Filter ¶
Filter returns a derivative query with a field-based filter. The filterStr argument must be a field name followed by optional space, followed by an operator, one of ">", "<", ">=", "<=", or "=". Fields are compared against the provided value using the operator. Multiple filters are AND'ed together.
func (*Query) KeysOnly ¶
KeysOnly returns a derivative query that yields only keys, not keys and entities. It cannot be used with projection queries.
func (*Query) MarshalJSON ¶
func (*Query) NamespaceAll ¶
NamespaceAll returns a derivative query specifying all namespaces
func (*Query) NamespaceEmpty ¶
NamespaceEmpty returns a derivative query specifying the empty namespace
func (*Query) NamespaceNamed ¶
NamespaceNamed returns a derivative query specifying the none-empty namespaces
type ShardLifecycle ¶
type ShardLifecycle interface { // ShardStarted is called when a mapper job for an individual // shard within a namespace is started ShardStarted(c context.Context, id string, namespace string, shard int) // ShardStarted is called when a mapper job for an individual // shard within a namespace is completed ShardCompleted(c context.Context, id string, namespace string, shard int) }
ShardLifecycle is the interface that any mapper job struct can implement to be notified of shard lifecycle events. Use this is you want to perform any actions at the beginning and / or end of processing for each shard.
type SliceLifecycle ¶
type SliceLifecycle interface { // SliceStarted is called when a mapper job for an individual slice of a // shard within a namespace is started SliceStarted(c context.Context, id string, namespace string, shard, slice int) // SliceStarted is called when a mapper job for an individual slice of a // shard within a namespace is completed SliceCompleted(c context.Context, id string, namespace string, shard, slice int) }
SliceLifecycle is the interface that any mapper job struct can implement to be notified of slice lifecycle events. Use this is you want to perform any actions at the beginning and / or end of processing for each slice.