Code Monkey home page Code Monkey logo

kclpy's Introduction

KCLPY -- Docker

Amazon Kinesis Client Library for Python

This is a base image for running a Kinesis Client Library application with Python. It's designed to require a minimal amount of code to process Kinesis records.

Using the KCLPY image

To use the KCLPY image, you'll need the following things in a directory:

  1. main.py -- A Python module that implements the RecordProcessor class methods from the Python KCL library.
  2. main.properties -- A properties file for the KCL. An example can be found here.
  3. A Dockerfile to build your image.

Additional details on each can be found below. You can find an example in the example directory.

Python RecordProcessor implementation

Read the AWS documentation on the RecordProcessor class implementation.

Amazon has given a sample implementation of the RecordProcessor class here. It includes all logic necessary except the processing of a single record. I've included it in /code/base.py in the Docker image, so you can import it and subclass if you like. Then you'll only need to implement the process_record method to use it.

Example main.py:

#!/usr/bin/env python
from amazon_kclpy import kcl
from base import RecordProcessor

class ExampleProcessor(RecordProcessor):

    def process_record(self, data, partition_key, sequence_number):
        print data

if __name__ == "__main__":
    kclprocess = kcl.KCLProcess(ExampleProcessor())
    kclprocess.run()

Dockerfile requirements.

Your Dockerfile should look similar to the following:

FROM alexdebrie/kclpy

ENV AWS_ACCESS_KEY=<yourkey>
ENV AWS_SECRET_KEY=<yourkey>

Make sure the credentials you use have the proper IAM permissions to perform the actions. If you are using the base RecordProcessor logic, this includes read access to your Kinesis stream as well as access to a DynamoDB table for checkpointing.

You may add additional steps to properly set up your environment (e.g. install packages, set environment variables) as needed.

The base image will copy and chmod your root directory. It will also run the CMD needed to start the KCL application.

kclpy's People

Contributors

alexdebrie avatar nathandemaria avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.