Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '0 0 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ check: $(STATICCHECK)
$(STATICCHECK) ./pkg/stream

test: vet fmt check
go test -v ./pkg/stream -race -coverprofile=coverage.txt -covermode=atomic -tags debug
go test -v ./pkg/stream -race -coverprofile=coverage.txt -covermode=atomic -tags debug #-ginkgo.v

integration-test: vet fmt check
cd ./pkg/system_integration && go test -v . -race -coverprofile=coverage.txt -covermode=atomic -tags debug -timeout 99999s
Expand Down
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,18 @@ go run perfTest/perftest.go silent
---

The API are composed by mandatory and optional arguments.
The optional be set in the standard go way as:
To set the optional parameters you can use builders:

```golang
env, err := stream.NewEnvironment(
stream.NewEnvironmentOptions().
SetHost("localhost").
SetPort(5552).
SetUser("guest").
SetPassword("guest"))
```

or standard way:
```golang
env, err := stream.NewEnvironment(
&stream.EnvironmentOptions{
Expand All @@ -55,26 +65,13 @@ env, err := stream.NewEnvironment(
)
```

or using builders ( the suggested way):

```golang
env, err := stream.NewEnvironment(
stream.NewEnvironmentOptions().
SetHost("localhost").
SetPort(5552).
SetUser("guest").
SetPassword("guest"))
```

`nil` is also a valid value, default values will be provided:

```golang
env, err := stream.NewEnvironment(nil)
```

The suggested way is to use builders.


### Build from source
---

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7-alpha
0.8-alpha
7 changes: 4 additions & 3 deletions examples/getting_started.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ func main() {
chPublishConfirm := producer.NotifyPublishConfirmation()
handlePublishConfirm(chPublishConfirm)

// each publish sends a number of messages, the batchMessages should be around 100 messages for send
for i := 0; i < 2; i++ {
_, err := producer.BatchPublish(CreateArrayMessagesForTesting(10))
// the send method automatically aggregates the messages
// based on batch size
for i := 0; i < 1000; i++ {
err := producer.Send(amqp.NewMessage([]byte("hello_world_" + strconv.Itoa(i))))
CheckErr(err)
}

Expand Down
89 changes: 89 additions & 0 deletions examples/haProducer/http/http.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package http

import (
"encoding/json"
"github.com/pkg/errors"
"io/ioutil"
"net/http"
"strconv"
)

type queue struct {
Messages int `json:"messages"`
}

type connection struct {
Name string `json:"name"`
}

func messagesReady(queueName string, port string) (int, error) {
bodyString, err := httpGet("http://localhost:"+port+"/api/queues/%2F/"+queueName, "guest", "guest")
if err != nil {
return 0, err
}

var data queue
err = json.Unmarshal([]byte(bodyString), &data)
if err != nil {
return 0, err
}
return data.Messages, nil
}

func Connections(port string) ([]connection, error) {
bodyString, err := httpGet("http://localhost:"+port+"/api/connections/", "guest", "guest")
if err != nil {
return nil, err
}

var data []connection
err = json.Unmarshal([]byte(bodyString), &data)
if err != nil {
return nil, err
}
return data, nil
}

func DropConnection(name string, port string) error {
_, err := httpDelete("http://localhost:"+port+"/api/connections/"+name, "guest", "guest")
if err != nil {
return err
}

return nil
}
func httpGet(url, username, password string) (string, error) {
return baseCall(url, username, password, "GET")
}

func httpDelete(url, username, password string) (string, error) {
return baseCall(url, username, password, "DELETE")
}

func baseCall(url, username, password string, method string) (string, error) {
var client http.Client
req, err := http.NewRequest(method, url, nil)
if err != nil {
return "", err
}
req.SetBasicAuth(username, password)

resp, err3 := client.Do(req)

if err3 != nil {
return "", err3
}

defer resp.Body.Close()

if resp.StatusCode == 200 { // OK
bodyBytes, err2 := ioutil.ReadAll(resp.Body)
if err2 != nil {
return "", err2
}
return string(bodyBytes), nil

}
return "", errors.New(strconv.Itoa(resp.StatusCode))

}
Loading