Top 4.7% dependent repos on proxy.golang.org
proxy.golang.org : github.com/santhosh-tekuri/fnet
Package fnet provides programmable firewall, bandwidth to test network failures in unit testing. This package (fnet stands for fakenet) is intended for use in unit-testing network related failures. Your library does not need any dependency on this package for this. only your tests need this package as dependency. This package simply wraps net.Listen, net.Dial, net.Conn implementation on tcp:localhost. It enforces firewall/bandwidth before delegating to actual implementation Some minimal changes needs to be done in your library for this. Consider following simple library code, to demonstrate the changes: You have to mock net.Listen, net.Dial in your code. For this introduce transport interface as shown below: You can mock net.Listen, net.Dial and net.DialTimeout using this package as shown above. Now you can various network failures as shown above using fnet.Firewall fnet.Bandwidth This package provides 3 implementations of firewall: AllowAll: This does not block any network traffic. This is the default firewall set on newly created network. AllowSelf: This blocks traffic between distinct hosts. Note that traffic within the host is allowed. Consider network with hosts m1, m2, m3 and m4, AllowSelf creates 4 network partitions: m1 | m2 | m3 | m4 Split: This implements network partioning. Mutiple partitions can be defined by chaining. See example below: You can create your own firewall implementation if needed. It is simple single method interface: to set bandwidth between two hosts:
Registry
-
Source
- Documentation
- JSON
- codemeta.json
purl: pkg:golang/github.com/santhosh-tekuri/fnet
Keywords:
bandwidth
, clusters
, golang
, network-failures
, split-brain
, testing
License: Apache-2.0
Latest release: over 6 years ago
First release: over 6 years ago
Namespace: github.com/santhosh-tekuri
Dependent packages: 1
Dependent repositories: 1
Stars: 1 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: about 2 months ago