examples

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2018 License: Apache-2.0 Imports: 0 Imported by: 0

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.

Documentation

Overview

Package examples contains examples that demonstrate the usage of various cn-infra components.

Directories

Path Synopsis
Example demonstrates creating a Bolt plugin
Example demonstrates creating a Bolt plugin
Example application "cassandra-lib" demonstrates the usage of the cassandra library in a plain go program.
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.
Example program "configs-plugin" demonstrates the usage of PluginConfig API.
Example application "cryptodata-plugin" demonstrates the usage of the cryptodata API.
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 "cryptodata-proto-plugin" demonstrates the usage of the cryptodata API.
ipsec
Package ipsec is a generated protocol buffer package.
Package ipsec is a generated protocol buffer package.
Example application "datasync-plugin" demonstrates the usage of the datasync 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.
Package etcdlib contains a collection of examples demonstrating the usage of the etcd library.
editor
Example program "editor" demonstrates CREATE/UPDATE/DELETE operations with etcd library.
Example program "editor" demonstrates CREATE/UPDATE/DELETE operations with etcd library.
view
Example program "view" shows how to read data from etcd datastore.
Example program "view" shows how to read data from etcd datastore.
watcher
Example program *watcher* shows how to watch for changes in etcd datastore.
Example program *watcher* shows how to watch for changes in etcd datastore.
Example program "flags-lib" demonstrates how to register CLI flags and how to display their runtime values.
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 grpcplugin contains grpc server & grpc client example.
grpc-server
Example demonstrates the use of GRPC plugin API.
Example demonstrates the use of GRPC plugin API.
Package kafkalib contains multiple examples with the kafka library.
Package kafkalib contains multiple examples with the kafka library.
asyncproducer
Asyncproducer is a simple command line tool for sending messages to Kafka using an asynchronous Kafka producer.
Asyncproducer is a simple command line tool for sending messages to Kafka using an asynchronous Kafka producer.
consumer
Consumer is a simple command line tool for consuming a Kafka topic and printing the received messages to the stdout.
Consumer is a simple command line tool for consuming a Kafka topic and printing the received messages to the stdout.
mux
Mux is a simple command line tool demonstrating the usage of Kafka multiplexer API.
Mux is a simple command line tool demonstrating the usage of Kafka multiplexer API.
syncproducer
Syncproducer is simple command line tool for sending messages to Kafka using a synchronous Kafka producer.
Syncproducer is simple command line tool for sending messages to Kafka using a synchronous Kafka producer.
utils
Package utils implements various tools used in examples for Kafka library.
Package utils implements various tools used in examples for Kafka library.
Package kafkaplugin contains multiple examples with the kafka plugin.
Package kafkaplugin contains multiple examples with the kafka plugin.
hash-partitioner
Example "hash-partitioner" demonstrates the use of Kafka plugin API with automatic (hash-based) partitioning.
Example "hash-partitioner" demonstrates the use of Kafka plugin API with automatic (hash-based) partitioning.
manual-partitioner
Example "manual-partitioner" demonstrates the use of Kafka plugin API with a focus on manual partitioning.
Example "manual-partitioner" demonstrates the use of Kafka plugin API with a focus on manual partitioning.
post-init-consumer
Example "later-stage" demonstrates the use partition watcher initialized and used after multiplexer Init()
Example "later-stage" demonstrates the use partition watcher initialized and used after multiplexer Init()
Package logslib contains multiple examples showing how to use the logger library with a focus on switching between the log levels.
Package logslib contains multiple examples showing how to use the logger library with a focus on switching between the log levels.
basic
Example "basic" presents the most commonly used APIs of the logger library.
Example "basic" presents the most commonly used APIs of the logger library.
custom
Example "custom" shows how to customize the logger.
Example "custom" shows how to customize the logger.
http
Example "http" demonstrates how to change the log level remotely via REST.
Example "http" demonstrates how to change the log level remotely via REST.
Example "logs-plugin" shows how to use the logger library from a simple plugin.
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.
Package etcdexample explains how to generate Golang structures from protobuf-formatted data.
Package redislib contains a collection of examples demonstrating the usage of the redis library.
Package redislib contains a collection of examples demonstrating the usage of the redis library.
airport
A bit more advanced example demonstrating the redis library API.
A bit more advanced example demonstrating the redis library API.
airport/model
Package flight defines protobuf-formatted data as used by the airport example.
Package flight defines protobuf-formatted data as used by the airport example.
simple
A simple example demonstrating the redis library API.
A simple example demonstrating the redis library API.
Example demonstrates creating a Redis plugin
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 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.
Example application "statuscheck-plugin" demonstrates the usage of statusCheck plugin etcd-plugin is monitored by StatusCheck plugin and examplePlugin reads the state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL