# README

CN-infra examples

The examples folder contains several executable examples (built from their respective main.go files) used to illustrate the cn-infra functionality. While most of the examples show a very simple use case, they still often need to connect to ETCD/Redis and/or Kafka. Therefore, you need to have instances of Etcd, Redis and Kafka running prior to starting examples.

Examples with the suffix -lib demonstrate the usage of CN-Infra APIs in generic Go programs. You can simply import the CN-Infra library where the API is declared into your program and start using the API.

Examples with the suffix -plugin demonstrate the usage of CN-Infra APIs within the context of plugins. Plugins are the basic building blocks of any given CN-Infra application. The CN-Infra plugin framework provides plugin initialization and graceful shutdown and supports uniform dependency injection mechanism to manage dependencies between plugins.

Current examples:

  • cassandra-lib shows how to use the Cassandra data broker API to access the Cassandra database,
  • datasync-plugin demonstrates the usage of the data synchronization APIs of the datasync package inside an example plugin,
  • etcd-lib shows how to use the ETCD data broker API to write data into ETCD and catch this change as an event by the watcher,
  • flags-lib registers flags and shows their runtime values in an example plugin,
  • kafka-lib shows how to use the Kafka messaging library on a set of individual tools (sync and async producer, consumer, mux),
  • kafka-plugin (hash-partitioner) contains a simple plugin which registers a Kafka consumer on specific topics and sends multiple test messages,
  • kafka-plugin (manual-partitioner) contains a simple plugin which registers a Kafka consumer watching on specific topics/partitions/offsets and sends multiple test messages,
  • logs-lib shows how to use the logger library and switch between the log levels,
  • logs-plugin shows how to use the logger library in a simple plugin,
  • redis-lib contains several examples that use the Redis data broker API,
  • model shows how to define a custom data model using Protocol Buffers and how to integrate it into an application,
  • simple-agent demonstrates how easily a set of CN-infra based plugins can be turned into an application.

# Packages

Example demonstrates creating a Bolt plugin.
Example application "cassandra-lib" demonstrates the usage of the cassandra library in a plain go program.
Example program "configs-plugin" demonstrates the usage of PluginConfig API.
No description provided by the author
No description provided by the author
Example application "cryptodata-plugin" demonstrates the usage of the cryptodata API.
Example application "cryptodata-proto-plugin" demonstrates the usage of the cryptodata API.
Example application "datasync-plugin" demonstrates the usage of the datasync API.
Package etcdlib contains a collection of examples demonstrating the usage of the etcd library.
Example program "flags-lib" demonstrates how to register CLI flags and how to display their runtime values.
Package grpcplugin contains grpc server & grpc client example.
Package kafkalib contains multiple examples with the kafka library.
Package kafkaplugin contains multiple examples with the kafka plugin.
Package logslib contains multiple examples showing how to use the logger library with a focus on switching between the log levels.
Example "logs-plugin" shows how to use the logger library from a simple plugin.
Package etcdexample explains how to generate Golang structures from protobuf-formatted data.
No description provided by the author
No description provided by the author
Package redislib contains a collection of examples demonstrating the usage of the redis library.
Example demonstrates creating a Redis plugin.
Example simple-agent shows how easily a set of CN-infra based plugins can be turned into an application.
Example application "statuscheck-plugin" demonstrates the usage of statusCheck plugin etcd-plugin is monitored by StatusCheck plugin and examplePlugin reads the state.
No description provided by the author
No description provided by the author