Package

org.coursera.naptime

ari

Permalink

package ari

This ari defines the key abstractions for automatic resource inclusion as well as GraphQL.

The system is split up into 3 distinct layers:

+---------------------------------------------------------------------+
|                       Presentation Layer                            |
|           GraphQL            |            Naptime HTTP              |
+------------------------------+--------------------------------------+
|                                                                     |
|                      Inclusion Engine                               |
|                                                                     |
+---------------------------------------------------------------------+
|                        Data fetching                                |
|         Local execution      |           remote execution           |
+=====================================================================+
|                                                                     |
|                   Unmodified Naptime APIs                           |
|                                                                     |
+---------------------------------------------------------------------+

A request enters the system via the presentation layer (typically parsed from the network). The presentation layer constructs a org.coursera.naptime.ari.Request and passes that to engine. The engine performs a number of validations against the schema, and then makes a number of requests to to the Data Fetching layer to assemble all of the (available) data required to construct a response. This is passed back to the presentation layer, which constructs a response to be sent out on the wire.

The API between the presentation layer and the inclusion engine is the org.coursera.naptime.ari.EngineApi

The API between the inclusion engine and the data fetching layer is defined by org.coursera.naptime.ari.FetcherApi.

BEWARE: This code is currently in a high state of flux. Do not depend upon it unless you are prepared for breakages!

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ari
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. trait FetcherApi extends AnyRef

    Permalink

    The fetcher calls the Naptime APIs (either local or remote) to acquire all of the data necessary.

  2. case class FullSchema(resources: Set[Resource], types: Set[DataSchema]) extends Product with Serializable

    Permalink

    Contains the complete set of static type information to fully specify a Naptime service.

    Contains the complete set of static type information to fully specify a Naptime service.

    resources

    The Resource schemas for all available resources.

    types

    All of the data types that compose the service.

  3. class LocalSchemaProvider extends SchemaProvider with StrictLogging

    Permalink

    Implements a default schema provider for local-only ARI operation.

  4. case class Request(requestHeader: RequestHeader, topLevelRequests: Seq[TopLevelRequest]) extends Product with Serializable

    Permalink

    This encapsulates all of the information needed to compute a response.

    This encapsulates all of the information needed to compute a response.

    requestHeader

    The request header is used for authentication parsing in the underlying requests made. Path and query parameters included in the request header are ignored in favor of the data within the topLevelRequests fields.

    topLevelRequests

    A non-empty list of "roots" used to begin queries. Every query begins with a "base" resource and related models are joined upon it from there.

  5. case class RequestField(name: String, alias: Option[String], args: Set[(String, JsValue)], selections: List[RequestField], typeCondition: Option[String] = None) extends Product with Serializable

    Permalink

    Represents a requested field within a requested resource.

    Represents a requested field within a requested resource.

    TODO: figure out directives

    name

    The name of the requested field.

    alias

    The name the field should be renamed to in the response.

    args

    If the field takes parameters, they are encapsulated here.

    selections

    The list of fields in the related resource.

  6. case class Response(topLevelResponses: Map[TopLevelRequest, TopLevelResponse], data: Map[ResourceName, Map[AnyRef, DataMap]], metrics: ResponseMetrics = ResponseMetrics()) extends Product with Serializable

    Permalink

    All of the data required to assemble a response to an automatic includes query.

    All of the data required to assemble a response to an automatic includes query.

    TODO: performance test, and determine if mutable collections yield non-trivial performance improvements.

    topLevelResponses

    A map from the top level requests to a TopLevelResponse, containing ids and pagination

    data

    A map from the resource name to a Map of IDs to DataMaps.

  7. case class ResponseMetrics(numRequests: Int = 0, duration: FiniteDuration = FiniteDuration(0, "seconds")) extends Product with Serializable

    Permalink
  8. trait SchemaProvider extends AnyRef

    Permalink

    Provides the metadata required to power the engine.

    Provides the metadata required to power the engine.

    For local-only operation, a LocalSchemaProvider implements this interface. For distributed operations, a more sophisticated SchemaProvider must be implemented.

  9. case class TopLevelRequest(resource: ResourceName, selection: RequestField, alias: Option[String] = None) extends Product with Serializable

    Permalink

    Encapsulates the starting root of a query into the naptime resource tree.

    Encapsulates the starting root of a query into the naptime resource tree.

    resource

    The name of the resource that forms the root of the request.

    selection

    The field selection on the first resource.

  10. case class TopLevelResponse(ids: DataList, pagination: ResponsePagination, url: Option[String] = None) extends Product with Serializable

    Permalink

    Represents the response data from a TopLevelRequest, including returned ids and pagination

    Represents the response data from a TopLevelRequest, including returned ids and pagination

    ids

    a list of IDs returned by the top level request. (i.e. ids 5, 6, and 7 were returned by the bySlug finder)

    pagination

    pagination info from the top level request, including total and next cursor

    url

    the downstream url used to fetch the data

Value Members

  1. object FullSchema extends Serializable

    Permalink
  2. object Response extends Serializable

    Permalink
  3. package engine

    Permalink
  4. package fetcher

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped