Skip to content

Capacitor wrapper that enables mobile devices to produce real-time events to a Fluvio Cluster.

License

Notifications You must be signed in to change notification settings

infinyon/fluvio-client-capacitor

Repository files navigation

Fluvio Capacitor Plugin

This project is a mobile app plugin written in HTML/JS/CSS with Capacitor that shows you how to connect mobile devices with Fluvio. Connecting your mobile devices directly to a Fluvio cluster without an intermediary backend server reduces latency and the load on other backend services.

Fluvio-capacitor

What is Fluvio?

Fluvio is an end-to-end distributed data streaming platform that makes it easy to build and run real-time applications. With Fluvio, you can ingest, transform, and dispatch large volumes of events from your mobile devices to backend servers. It connects your devices from edge to core, removing the complexity of building and scaling your middle tier.

Who should use this?

Anyone who is building native mobile applications with a low tolerance for latency. For example:

  • track cars, trucks, or buses on a map
  • monitor stocks and send alerts
  • compute gaming stats
  • collect health monitoring data
  • monitoring traffic conditions
  • etc.

Prerequisites

  1. Clone this project

    git clone [email protected]:infinyon/fluvio-client-capacitor.git
  2. Install Capacitor

    Your computer must have Capacitor installed with an IOS runtime. Checkout the Capacitor iOS Documentation for additional instructions.

Setup Fluvio

  1. Install Fluvio client:

    Download Fluvio client to your local machine.

  2. Provision a Fluvio cluster:

    Infinyon Cloud - create free account and provision a cluster.

Run the Example App

The Sample App in the example directory to demonstrate Fluvio capatibities.

  1. In the terminal, open the example directory

    cd example
  2. Use Fluvio CLI to login to Fluvio Cloud

    fluvio cloud login
  3. Download your fluvio profile in the www directory. This file contains your security profile that allows mobiles devices to connect to InfinyOn cloud.

    fluvio profile export > www/fluvio-profile.json
  4. Create topic in fluvio

    fluvio topic create cap-example
  5. Build the Sample App

    npm install && npm run build
  6. Sync to native projects

    npx cap sync
  7. (iOS) Open XCode to deploy to simulator

    npx cap open ios

Congratulations! Your enviornment is up and running. Use the GUI to send some records and read from the consumer in the CLI.

Integrate Fluvio into your own Capacitor App

  1. Use npm to install the Fluvio capacitor client in your own app:

    npm install --save https://github.com/infinyon/fluvio-client-capacitor/releases/latest/download/fluvio-client-capacitor.tgz
  2. Sample code to produce records

    import { FluvioClient } from '@fluvio/client-capacitor';
    import fluvioProfile from './fluvio-profile.json';
    
    const FLUVIO_TOPIC = 'cap-example';
    
    async function example() {    
        let fluvioClient = await FluvioClient.connect(fluvioProfile);
        await fluvioClient.produce(FLUVIO_TOPIC, "example value");
    }

APIs

FluvioClient

Methods

  • static connect(profile: Profile): Promise<FluvioClient>

  • produce(topic: String, value: String): Promise<void>

FluvioProfile

Properties

FluvioProfileTls

Properties

  • policy: string
  • domain: string
  • key: string
  • cert: string
  • ca_cert: string

References

Limitations

This project is currently under development and we are seeking help from the community on the following features:

Join our community on Discord and let's build the future of data streaming together.