httpmq-go

command module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 4 Imported by: 0

README

HTTP MQ - Go Client

Golang client for httpmq

MIT Go Report Card CICD workflow

Table of Content


1. Introduction

This Golang client is built upon the auto-generated client SDK of httpmq's OpenAPI specification. Tho auto-generated SDK is placed under the api package.

NOTE: Some modifications were made to the autogenerated SDK to correct the data types.

Though one can use the generated code in the api package directly, a more user friendly wrapper API is provided through the following packages:

  • common: support and utility code.
  • management: interact with httpmq's management API group.
  • dataplane: interact with httpmq's dataplane API group.

2. Installation

$ GO111MODULE=on go get github.com/alwitt/httpmq-go
import (
   hmqCommon "github.com/alwitt/httpmq-go/common"
   hmqData "github.com/alwitt/httpmq-go/dataplane"
   hmqCtrl "github.com/alwitt/httpmq-go/management"
)

3. Examples

4. Local Development

NOTE: Though the described procedures supports local development, the same docker-compose.yaml can be used to create a httpmq test environment independent of this project.

A helper Makefile is included to automate the common development tasks. The available make targets are:

$ make help
lint                           Lint the files
fix                            Lint and fix vialoations
compose                        Run docker-compose to create the DEV ENV
test                           Run unittests
build                          Build the test application
clean                          Clean up DEV ENV
help                           Display this help screen

First, start the development environment:

$ make compose
Removing httpmq-go_httpmq-mgmt_1 ... done
Removing httpmq-go_httpmq-data_1 ... done
Removing httpmq-go_dev-nats_1    ... done
Removing network httpmq-go_httpmq-go-test
Creating network "httpmq-go_httpmq-go-test" with driver "bridge"
Creating httpmq-go_httpmq-data_1 ... done
Creating httpmq-go_httpmq-mgmt_1 ... done
Creating httpmq-go_dev-nats_1    ... done

Verify the components are running:

$ docker ps
CONTAINER ID   IMAGE                 COMMAND                  CREATED              STATUS              PORTS                          NAMES
3b4ed2266732   nats:2.6.2            "/nats-server --conf…"   About a minute ago   Up About a minute   4222/tcp, 6222/tcp, 8222/tcp   httpmq-go_dev-nats_1
9406866489fb   alwitt/httpmq:0.2.0   "/usr/bin/httpmq.bin…"   About a minute ago   Up About a minute   127.0.0.1:4000->3000/tcp       httpmq-go_httpmq-mgmt_1
0c0a1692e202   alwitt/httpmq:0.2.0   "/usr/bin/httpmq.bin…"   About a minute ago   Up About a minute   127.0.0.1:4001->3000/tcp       httpmq-go_httpmq-data_1

Verify the code builds and passes unit-tests:

$ make
$ make test
?   	github.com/alwitt/httpmq-go	[no test files]
?   	github.com/alwitt/httpmq-go/api	[no test files]
?   	github.com/alwitt/httpmq-go/cmd	[no test files]
?   	github.com/alwitt/httpmq-go/common	[no test files]
ok  	github.com/alwitt/httpmq-go/dataplane	0.065s
ok  	github.com/alwitt/httpmq-go/management	0.097s

The demo application built is httpmq-test-cli.bin. It exercises all the functionalities of the APIs. These functionalities are separated into subcommands, and the associated usage message explains how to call each functionality.

$ ./httpmq-test-cli.bin -h
NAME:
   httpmq-test-cli.bin - HTTP MQ demo application

USAGE:
   httpmq-test-cli.bin [global options] command [command options] [arguments...]

VERSION:
   v0.1.0

DESCRIPTION:
   Demo application for trying out functionalities of httpmq

COMMANDS:
   management, mgmt  management API client
   dataplane, data   dataplane API client
   help, h           Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help (default: false)
   --version, -v  print the version (default: false)
$ ./httpmq-test-cli.bin management -h
NAME:
   httpmq-test-cli.bin management - management API client

USAGE:
   httpmq-test-cli.bin management command [command options] [arguments...]

DESCRIPTION:
   Operate the httpmq management API

COMMANDS:
   stream    Manage streams
   consumer  Manage consumers
   help, h   Shows a list of commands or help for one command

OPTIONS:
   --json-log, -j                           Whether to log in JSON format (default: false) [$LOG_AS_JSON]
   --log-level value, -l value              Logging level: [debug info warn error] (default: info) [$LOG_LEVEL]
   --custom-ca-file value, --ccf value      Custom CA file to use with HTTP client [$HTTP_CUSTOM_CA_FILE]
   --access-token value, --at value         Bearer access token used for authentication [$HTTP_BEARER_ACCESS_TOKEN]
   --management-server-url value, -s value  Management server URL (default: http://127.0.0.1:4000) [$MANAGEMENT_SERVER_URL]
   --help, -h                               show help (default: false)
$ ./httpmq-test-cli.bin management stream -h
NAME:
   httpmq-test-cli.bin management stream - Manage streams

USAGE:
   httpmq-test-cli.bin management stream command [command options] [arguments...]

DESCRIPTION:
   Manages streams through httpmq management API

COMMANDS:
   list                  List all streams
   create                Define a new stream
   get                   Fetch one stream
   delete                Delete one stream
   change-subject, cs    Change target subject of stream
   change-retention, ca  Change stream message retention
   help, h               Shows a list of commands or help for one command

OPTIONS:
   --help, -h  show help (default: false)
$ ./httpmq-test-cli.bin management consumer -h
NAME:
   httpmq-test-cli.bin management consumer - Manage consumers

USAGE:
   httpmq-test-cli.bin management consumer command [command options] [arguments...]

DESCRIPTION:
   Manages consumers through httpmq management API

COMMANDS:
   list     List all consumers
   get      Fetch one consumer
   create   Define a new consumer
   delete   Delete a consumer
   help, h  Shows a list of commands or help for one command

OPTIONS:
   --stream value, -s value  Target stream to operate against [$TARGET_STREAM]
   --help, -h                show help (default: false)
$ ./httpmq-test-cli.bin dataplane -h
NAME:
   httpmq-test-cli.bin dataplane - dataplane API client

USAGE:
   httpmq-test-cli.bin dataplane command [command options] [arguments...]

DESCRIPTION:
   Operate the httpmq dataplane API

COMMANDS:
   publish, pub    Publish messages
   subscribe, sub  Subscribe for messages
   help, h         Shows a list of commands or help for one command

OPTIONS:
   --json-log, -j                          Whether to log in JSON format (default: false) [$LOG_AS_JSON]
   --log-level value, -l value             Logging level: [debug info warn error] (default: info) [$LOG_LEVEL]
   --custom-ca-file value, --ccf value     Custom CA file to use with HTTP client [$HTTP_CUSTOM_CA_FILE]
   --access-token value, --at value        Bearer access token used for authentication [$HTTP_BEARER_ACCESS_TOKEN]
   --dataplane-server-url value, -s value  Dataplane server URL (default: http://127.0.0.1:4001) [$DATAPLANE_SERVER_URL]
   --help, -h                              show help (default: false)

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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