Giter Club home page Giter Club logo

akkaserverless-wirelessmesh-java's Introduction

Akka Serverless - Wireless Mesh Example App

A Java-based example app for Akka Serverless

Features include:

  • Customer locations with wireless mesh devices
  • Connectivity to Google Cloud Pubsub

What is this example?

To help you get started with Akka Serverless, we've built some example apps that showcase the capabilities of the platform. This example application mimics a company that uses Akka Serverless to keep track of the wireless mesh devices their customers have installed and the devices connected to the meshes.

In this example app you can interact with the devices, assign them to different rooms in the house, and turn them on or off. To make this example even more interactive, you can add an actual nightlight and switch the lights on or off.

Prerequisites

To build and deploy this example application, you'll need to have:

Build, Deploy, and Test

LIFX integration for toggling nightlight

If you have an LIFX bulb and would like it to stand in for a wirelessmesh device and have it light on/off when you toggle the device nightlight, you simply have to:

  • Have an operational bulb
  • When you create your customer location, be sure to set the access token to the authorizaton token you requested with LIFX.
  • When you activate the device in this app, make sure it has the same device id as your bulb.
  • More information [here][https://api.developer.lifx.com]

Prepare your Google Cloud Pubsub

To connect to Google Cloud Pubsub, the easiest method is authenticate using a service account. To create your service account. After creating your service account, you need to download the service account key as a JSON file called mycreds.json.

To publish events to google pubsub locally, set the environment variable GOOGLE_PROJECT_ID to match your project id. You will need to create a the topic '"'wirelessmesh'

examples to set local variables for testing (mac os):

  • export GOOGLE_APPLICATION_CREDENTIALS='/Users/memyselfandI/Downloads/mycreds.json'
  • export GOOGLE_PROJECT_ID='diesel-broccoli-266021'

Be sure to set GOOGLE_PROJECT_ID during your akkaserverless deploy as well.

Next, you'll need to build a base image that contains the mycreds.json file and sets the environment variable GOOGLE_APPLICATION_CREDENTIALS to the service account key. You can build the docker image with by running:

docker build -f prereq.Dockerfile . -t mybaseimage

the new container will be named mybaseimage and will be used in subsequent steps. Note that pushing containers with service account keys to a public docker registry is a potentially dangerous situation.

Build your container

To build your own container, follow the below steps

  1. If you haven't completed the previous step, because you don't need to connect to Google Cloud Pubsub, change mybaseimage on line 58 to adoptopenjdk/openjdk8
  2. Update line 56 of the pom.xml file with your Docker Hub username.
  3. Run mvn clean install

The command mvn clean install will create a new Docker image based on adoptopenjdk/openjdk8.

The result of the command should be

$ mvn clean install

...

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:31 min
[INFO] Finished at: 2021-01-20T16:20:29-08:00
[INFO] ------------------------------------------------------------------------

Deploy your container

To deploy the container as a service in Akka Serverless, you'll need to:

  1. Push the container to a container registry: docker push -t <registry url>/<registry username>/akkaserverless-wirelessmesh-java:latest
  2. Deploy the service in Akka Serverless: akkasls svc deploy wirelessmesh <registry url>/<registry username>/akkaserverless-wirelessmesh-java:latest

The above command will deploy your container to your default project with the name wirelessmesh. If you want to have a different name, you can change that.

Testing your service

To test using Postman.

Contributing

We welcome all contributions! Pull requests are the preferred way to share your contributions. For major changes, please open an issue first to discuss what you would like to change.

Support

This project is provided on an as-is basis and is not covered by the Lightbend Support policy.

License

See the LICENSE.

akkaserverless-wirelessmesh-java's People

Contributors

retgits avatar sean-walsh avatar

Stargazers

 avatar

Watchers

 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.