Skip to content
Open
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
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Contributing

We are open to, and grateful for, any contributions made by the community. By contributing to **message-bus**, you agree to abide by the [code of conduct](https://github.com/vardius/message-bus/blob/master/CODE_OF_CONDUCT.md).
We are open to, and grateful for, any contributions made by the community. By contributing to **message-bus**, you agree to abide by the [code of conduct](https://github.com/taills/message-bus/blob/master/CODE_OF_CONDUCT.md).

## Reporting Issues and Asking Questions

Before opening an issue, please search the [issue tracker](https://github.com/vardius/message-bus/issues) to make sure your issue hasn't already been reported.
Before opening an issue, please search the [issue tracker](https://github.com/taills/message-bus/issues) to make sure your issue hasn't already been reported.

### Bugs and Improvements

Expand All @@ -20,7 +20,7 @@ Please be considerate when doing this as this is not the primary purpose of the

## Development

Visit the [issue tracker](https://github.com/vardius/message-bus/issues) to find a list of open issues that need attention.
Visit the [issue tracker](https://github.com/taills/message-bus/issues) to find a list of open issues that need attention.

Fork, then clone the repo:

Expand All @@ -40,7 +40,7 @@ On the other hand, sometimes the best way to start a conversation *is* to send a

In general, the contribution workflow looks like this:

* Open a new issue in the [Issue tracker](https://github.com/vardius/message-bus/issues).
* Open a new issue in the [Issue tracker](https://github.com/taills/message-bus/issues).
* Fork the repo.
* Create a new feature branch based off the `master` branch.
* Make sure all tests pass and there are no linting errors.
Expand Down
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
🚌 message-bus
================
[![Build Status](https://travis-ci.org/vardius/message-bus.svg?branch=master)](https://travis-ci.org/vardius/message-bus)
[![Go Report Card](https://goreportcard.com/badge/github.com/vardius/message-bus)](https://goreportcard.com/report/github.com/vardius/message-bus)
[![codecov](https://codecov.io/gh/vardius/message-bus/branch/master/graph/badge.svg)](https://codecov.io/gh/vardius/message-bus)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fvardius%2Fmessage-bus.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fvardius%2Fmessage-bus?ref=badge_shield)
[![](https://godoc.org/github.com/vardius/message-bus?status.svg)](https://pkg.go.dev/github.com/vardius/message-bus)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/vardius/message-bus/blob/master/LICENSE.md)
[![Build Status](https://travis-ci.org/taills/message-bus.svg?branch=master)](https://travis-ci.org/taills/message-bus)
[![Go Report Card](https://goreportcard.com/badge/github.com/taills/message-bus)](https://goreportcard.com/report/github.com/taills/message-bus)
[![codecov](https://codecov.io/gh/taills/message-bus/branch/master/graph/badge.svg)](https://codecov.io/gh/taills/message-bus)
[![](https://godoc.org/github.com/taills/message-bus?status.svg)](https://pkg.go.dev/github.com/taills/message-bus)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/taills/message-bus/blob/master/LICENSE.md)

<img align="right" height="180px" src="website/src/static/img/logo.png" alt="logo" />

Go simple async message bus.

> **Note**: This repository is forked from [github.com/vardius/message-bus](https://github.com/vardius/message-bus)

📖 ABOUT
==================================================
Contributors:
Expand All @@ -20,26 +21,33 @@ Contributors:
Want to contribute ? Feel free to send pull requests!

Have problems, bugs, feature ideas?
We are using the github [issue tracker](https://github.com/vardius/message-bus/issues) to manage them.
We are using the github [issue tracker](https://github.com/taills/message-bus/issues) to manage them.

## 📚 Documentation

For **documentation** (_including examples_), **visit [rafallorenz.com/message-bus](http://rafallorenz.com/message-bus)**

For **GoDoc** reference, **visit [pkg.go.dev](https://pkg.go.dev/github.com/vardius/message-bus)**
For **GoDoc** reference, **visit [pkg.go.dev](https://pkg.go.dev/github.com/taills/message-bus)**

🚏 HOW TO USE
==================================================

## 🚅 Benchmark

```bash
➜ message-bus git:(master) ✗ go test -bench=. -cpu=4 -benchmem
go test -bench=. -cpu=8 -benchmem
goos: darwin
goarch: amd64
pkg: github.com/vardius/message-bus
BenchmarkPublish-4 4430224 250 ns/op 0 B/op 0 allocs/op
BenchmarkSubscribe-4 598240 2037 ns/op 735 B/op 5 allocs/op
goarch: arm64
pkg: github.com/taills/message-bus
cpu: Apple M3 Max
BenchmarkPublish-8 9355280 128.8 ns/op 0 B/op 0 allocs/op
BenchmarkSubscribe-8 2483044 532.5 ns/op 824 B/op 6 allocs/op
Benchmark1Subscriber1Topic-8 10066575 119.5 ns/op 0 B/op 0 allocs/op
Benchmark1Subscriber100Topics-8 9209472 141.7 ns/op 0 B/op 0 allocs/op
Benchmark100Subscribers1Topic-8 180798 5714 ns/op 0 B/op 0 allocs/op
Benchmark100Subscribers100Topics-8 158925 6465 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/taills/message-bus 42.235s
```

👉 **[Click here](https://rafallorenz.com/message-bus/docs/benchmark)** to see all benchmark results.
Expand All @@ -56,6 +64,4 @@ BenchmarkSubscribe-4 598240 2037 ns/op 735 B/op
📜 [License](LICENSE.md)
-------

This package is released under the MIT license. See the complete license in the package:

[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fvardius%2Fmessage-bus.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fvardius%2Fmessage-bus?ref=badge_large)
This package is released under the MIT license. See the complete license in the package.
6 changes: 4 additions & 2 deletions bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,20 @@ func (b *messageBus) Unsubscribe(topic string, fn interface{}) error {

if _, ok := b.handlers[topic]; ok {
for i, h := range b.handlers[topic] {
if h.callback == rv {
if h.callback.Pointer() == rv.Pointer() {
close(h.queue)

if len(b.handlers[topic]) == 1 {
delete(b.handlers, topic)
} else {
b.handlers[topic] = append(b.handlers[topic][:i], b.handlers[topic][i+1:]...)
}

return nil
}
}

return nil
return fmt.Errorf("handler not found for topic %s", topic)
}

return fmt.Errorf("topic %s doesn't exist", topic)
Expand Down
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"sync"

messagebus "github.com/vardius/message-bus"
messagebus "github.com/taills/message-bus"
)

func Example() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/vardius/message-bus
module github.com/taills/message-bus

go 1.12
2 changes: 1 addition & 1 deletion website/docs/basic-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"fmt"
"sync"

messagebus "github.com/vardius/message-bus"
messagebus "github.com/taills/message-bus"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/benchmark.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Time complexity of a `Publish` method is considered to be [linear time `O(n)`](h
➜ message-bus git:(master) ✗ go test -bench=. -cpu=4 -benchmem
goos: darwin
goarch: amd64
pkg: github.com/vardius/message-bus
pkg: github.com/taills/message-bus
BenchmarkPublish-4 4430224 250 ns/op 0 B/op 0 allocs/op
BenchmarkSubscribe-4 598240 2037 ns/op 735 B/op 5 allocs/op
```
6 changes: 3 additions & 3 deletions website/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ Package **messagebus** provides simple async message publisher.

## Installation

Install the [message-bus](https://github.com/vardius/message-bus) package by calling the following command:
Install the [message-bus](https://github.com/taills/message-bus) package by calling the following command:

```bash
go get -u github.com/vardius/message-bus
go get -u github.com/taills/message-bus
```

Import package as follow

```go
import "github.com/vardius/message-bus"
import "github.com/taills/message-bus"
```
6 changes: 3 additions & 3 deletions website/src/core/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Footer extends React.Component {
<a href={this.docUrl("installation.html", this.props.language)}>
Documentation
</a>
<a href="https://godoc.org/github.com/vardius/message-bus">GoDoc</a>
<a href="https://godoc.org/github.com/taills/message-bus">GoDoc</a>
</div>
<div>
<h5>Community</h5>
Expand All @@ -54,12 +54,12 @@ class Footer extends React.Component {
<div>
<h5>More</h5>
<a href="https://rafallorenz.com">rafallorenz.com</a>
<a href="https://github.com/vardius/message-bus">GitHub</a>
<a href="https://github.com/taills/message-bus">GitHub</a>
<a
className="github-button"
href={this.props.config.repoUrl}
data-icon="octicon-star"
data-count-href="/vardius/message-bus/stargazers"
data-count-href="/taills/message-bus/stargazers"
data-show-count="true"
data-count-aria-label="# stargazers on GitHub"
aria-label="Star this project on GitHub"
Expand Down
6 changes: 3 additions & 3 deletions website/src/pages/en/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ function Help(props) {
},
{
content:
"[Ask questions](https://github.com/vardius/message-bus/issues) about the documentation and project",
"[Ask questions](https://github.com/taills/message-bus/issues) about the documentation and project",
title: "Join the community"
},
{
content:
"Find out [what's new](https://github.com/vardius/message-bus/watchers) with this project",
"Find out [what's new](https://github.com/taills/message-bus/watchers) with this project",
title: "Stay up to date"
},
{
Expand All @@ -43,7 +43,7 @@ function Help(props) {
},
{
content:
"Contribute by [forking](https://github.com/vardius/message-bus/network/members) and improving this project",
"Contribute by [forking](https://github.com/taills/message-bus/network/members) and improving this project",
title: "Contribute"
}
];
Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"fmt"
"sync"

messagebus "github.com/vardius/message-bus"
messagebus "github.com/taills/message-bus"
)

func main() {
Expand Down Expand Up @@ -116,7 +116,7 @@ class HomeSplash extends React.Component {
<PromoSection>
<Button href={docUrl("installation.html")}>Documentation</Button>
<Button href={pageUrl("help")}>Help</Button>
<Button href="https://github.com/vardius/message-bus">GitHub</Button>
<Button href="https://github.com/taills/message-bus">GitHub</Button>
</PromoSection>
</div>
</SplashContainer>
Expand Down
6 changes: 3 additions & 3 deletions website/src/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const siteConfig = {

// Used for publishing and more
projectName: "message-bus",
organizationName: "vardius",
organizationName: "taills",
// For top-level user or org sites, the organization is still the same.
// e.g., for the https://JoelMarcey.github.io site, it would be set like...
// organizationName: 'JoelMarcey'
Expand All @@ -42,7 +42,7 @@ const siteConfig = {
{ doc: "installation", label: "Docs" },
{ page: "help", label: "Help" },
// { page: "users", label: "Users" },
{ href: "https://github.com/vardius/message-bus", label: "GitHub" }
{ href: "https://github.com/taills/message-bus", label: "GitHub" }
// { blog: true, label: 'Blog'},
// { languages: true },
// { search: true }
Expand Down Expand Up @@ -110,7 +110,7 @@ const siteConfig = {

// You may provide arbitrary config keys to be used as needed by your
// template. For example, if you need your repo's URL...
repoUrl: "https://github.com/vardius/message-bus",
repoUrl: "https://github.com/taills/message-bus",
gaTrackingId: "UA-42622274-2"
};

Expand Down