Package

io.keen.client

scala

Permalink

package scala

Package implementing an asynchronous, idiomatic Scala client for the Keen IO API.

Source
package.scala
See also

The project home on GitHub

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

Type Members

  1. sealed trait AccessLevel extends AnyRef

    Permalink

    A Client can mix in one or more AccessLevels to enable API calls for read, write, and master operations.

    A Client can mix in one or more AccessLevels to enable API calls for read, write, and master operations.

    The intention of this approach is to make it a compile-time error to call an API method requiring a write key if you haven't statically declared that the client should be a writer, for example.

    This also means that runtime checks for presence of optional settings (keys for access levels you don't need) are pushed up to the time of client instantiation: if you've forgotten to provide a write key in your deployment environment, we won't wait to throw a runtime exception at the point that you make a write call, perhaps long after your app has started and you've gone home for the weekend.

    Attributes
    protected
    Example:
    1. Client with read and write access:

      val keen = new Client with Reader with Writer
    See also

    https://keen.io/docs/security/

  2. class BatchWriterClient extends Client with Writer

    Permalink

    A BatchWriterClient is a Client specialized with the capability to write events to the Keen API in batches per request.

    A BatchWriterClient is a Client specialized with the capability to write events to the Keen API in batches per request.

    Each instance creates a threadpool and schedules flush operations on it, which will make bulk write calls to the Keen IO API for batches of events until the queue is drained.

    Events are queued for batch submission with queueEvent; other operations like addEvent function as with an ordinary Client with Writer—that is, they are non-blocking but effect discrete API calls per invocation.

    Batch size, flush scheduling, queue bounds, etc. can be tuned via the settings under the keen.queue property tree.

    To do

    Explain the difference in behavior if send-interval is zero seconds.

  3. class Client extends HttpAdapterComponent with Logging

    Permalink

    A keen.io API client.

    A keen.io API client. A plain Client instance doesn't do a whole lot—you'll want to mix in AccessLevels like Writer, Reader, or Master depending on the API operations that you need to perform.

    The client defaults to using a built-in adapter for the Spray HTTP toolkit for HTTP requests. Another HTTP client library can be plugged in by implementing the HttpAdapter interface.

    Example:
    1. Overriding the default HttpAdapter

      val keen = new Client {
        override val httpAdapter = new HttpAdapterDispatch
      }
    See also

    The Keen IO API Reference

  4. class ClientThreadFactory extends ThreadFactory

    Permalink
  5. trait EventStore extends AnyRef

    Permalink

    An EventStore is an abstract store for events, intended primarily as a write cache for events to be flushed in batches, such as by a BatchWriterClient.

    An EventStore is an abstract store for events, intended primarily as a write cache for events to be flushed in batches, such as by a BatchWriterClient.

    The documentation refers to "handles", which you can think of simply as cache keys or map keys in common parlance. The parameter naming is historical.

    To do

    The data structure should be generalized from TrieMap & ListBuffer

    ,

    The handle/key type could be generic instead of Long.

    ,

    I'd like to change parameter names to key before 1.0.

  6. trait HttpAdapter extends AnyRef

    Permalink

    A basic HTTP client abstraction.

    A basic HTTP client abstraction. This interface allows pluggable use of new HTTP client libraries of your choice for the Keen Client.

  7. trait HttpAdapterComponent extends AnyRef

    Permalink

    Expresses a dependency on an HttpAdapter, which an implementor or library user must provide.

  8. class HttpAdapterDispatch extends HttpAdapter

    Permalink

    An HttpAdapter built on the Dispatch HTTP client library.

    An HttpAdapter built on the Dispatch HTTP client library.

    To do

    Move the timeout constructor param to config; it's not used here!

  9. class HttpAdapterSpray extends HttpAdapter with Logging

    Permalink

    An HttpAdapter built on HTTP client support of the Spray HTTP toolkit.

    An HttpAdapter built on HTTP client support of the Spray HTTP toolkit.

    Akka and Actor Systems

    Spray is built upon Akka I/O and uses an Akka ActorSystem to handle HTTP I/O. By default, HttpAdapterSpray creates an ActorSystem for its own use so that it works out of the box. If you are using it within an Akka application, however, it is possible to specify the ActorSystem within which it will run using an implicit parameter.

    Examples:
    1. Using a custom ActorSystem, implicitly for a scope

      implicit val system = ActorSystem("myapp-system")
      val adapter = new HttpAdapterSpray
    2. ,
    3. Using a custom ActorSystem

      val adapter = new HttpAdapterSpray()(ActorSystem("myapp-system"))
    To do

    Move the timeout constructor param to config

  10. trait Master extends Reader with Writer

    Permalink

    A Client mixing in Master can make Keen IO API calls requiring a master key, such as deleting data, creating saved queries, and performing administrative functions.

    A Client mixing in Master can make Keen IO API calls requiring a master key, such as deleting data, creating saved queries, and performing administrative functions.

    A Master client can also perform all Reader and Writer API calls and does not require additional keys configured for these. However, this should not be considered a shortcut! Please keep your master key as secure as possible by not deploying it where it isn't strictly needed.

    A master key must be configured in the Client's Settings or the masterKey field must otherwise be set e.g. with an anonymous class override.

    Example:
    1. Initializing a Client with master access

      val keen = new Client with Master {
        override val masterKey = "myMasterKey"
      }
    Exceptions thrown

    MissingCredential if a master key is not configured.

    See also

    https://keen.io/docs/security/

  11. case class MissingCredential(cause: String) extends RuntimeException with Product with Serializable

    Permalink
  12. class RamEventStore extends EventStore

    Permalink

    RamEventStore implements the EventStore interface with an in-memory backing cache that is concurrency-safe.

    RamEventStore implements the EventStore interface with an in-memory backing cache that is concurrency-safe.

    It is the default EventStore implementation supporting batched write flushing functionality of BatchWriterClient.

    To do

    We're really getting nothing out of TrieMap's lock-free nature, every operation is wrapped in (coarse) synchronized blocks for sake of ListBuffer safety. The Java implementation doesn't use concurrent data structures at all, presumably for that reason. Use a simpler Map type, or even better, find ways to safely slim down the synchronized blocks.

  13. trait Reader extends AccessLevel

    Permalink

    A Client mixing in Reader can make Keen IO API calls requiring a read key.

    A Client mixing in Reader can make Keen IO API calls requiring a read key.

    A read key must be configured in the Client's Settings or the readKey field must otherwise be set e.g. with an anonymous class override.

    Example:
    1. Initializing a Client with read access

      val keen = new Client with Reader {
        override val readKey = "myReadKey"
      }
    Exceptions thrown

    MissingCredential if a read key is not configured.

    See also

    https://keen.io/docs/security/

  14. case class Response(statusCode: Int, body: String) extends Product with Serializable

    Permalink
  15. implicit final class RichConfig extends AnyVal

    Permalink

    Enrichment for Typesafe Config to wrap some optional settings in Option, or get Scala FiniteDuration values instead of java.time.Duration.

  16. class Settings extends AnyRef

    Permalink

    Configuration settings for Keen IO Client.

    Configuration settings for Keen IO Client.

    Settings can be parsed from config files, properties, environment variables, etc. as supported by Typesafe Config.

    Exceptions thrown

    ConfigException.Missing if required configuration keys are not provided.

    ConfigException.WrongType if a given configuration value is not of the required or sensibly coercible type.

  17. trait Writer extends AccessLevel

    Permalink

    A Client mixing in Writer can make Keen IO API calls requiring a write key.

    A Client mixing in Writer can make Keen IO API calls requiring a write key.

    A write key must be configured in the Client's Settings or the writeKey field must otherwise be set e.g. with an anonymous class override.

    Example:
    1. Initializing a Client with write access

      val keen = new Client with Writer {
        override val writeKey = "myWriteKey"
      }
    Exceptions thrown

    MissingCredential if a write key is not configured.

    See also

    https://keen.io/docs/security/

Value Members

  1. object BatchWriterClient

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped