Giter VIP home page Giter VIP logo

kiwf's Introduction

README IS WIP (lib is still unstable on macs, do not use in production)

go report card codecov CircleCI GoDoc

ISSUE with long running tests (macs)

go test -timeout 2400s -run ^Test_kiwf_Impl_3$ github.com/thisisdevelopment/kiwf -count=10000

These test fails sometimes

Introduction

Kill It With Fire ๐Ÿ”ฅ ๐Ÿ”ซ is an advanced, yet simple internal heartbeat library for golang. The library removes the need to implement your own timeout procedures using ctx/timeout/deadline/cancel routines. Timeout, delay and startup time can be configured. Also there's a possibility to pass in a map[string]interface{} that will be passed into a configurable ExitFunction. If no ExitFunction is configured a panic will be generated.

Basic usage

    // initialize 
    kiwf, err := New("my work", &Config{
        // delay for sometime to start monitoring
		DelayStartupTime: 10 * time.Millisecond,

        // duration we should kill or call function if we didnt receive a Tick in time
		Timeout:          150 * time.Millisecond,
	})
	if err != nil {
		// do sth with err
	}


    // start watching 
	kiwf.Start()

    // always call Close
	defer kiwf.Close()

    testTimeout := 500 * time.Millisecond
	startTime := time.Now()

    // simulate some work for approx 500ms and timeout
	for {
		kiwf.Tick()
		if time.Since(startTime) > testTimeout {
			break
		}
		time.Sleep(1 * time.Millisecond)
	}

    // simulate idleness, do nothing, take a nap
    time.Sleep(time.Second)

    // this should panic vvvv

    panic: Killed it with fire 'my work' time expired last action 150.833542ms ago. set timeout 150ms. passtru vars map[], time obj 2022-12-14 11:11:08.212809 +0100 CET m=+0.501677876


Contributing

You can help to deliver a better fire ๐Ÿ”ฅ ๐Ÿ”ซ killer, check out how you can do things CONTRIBUTING.md

License

ยฉ This is Development BV, 2022~time.Now() Released under the MIT License

kiwf's People

Contributors

thisisdev-patrick avatar mrkagelui avatar

Watchers

Robert avatar  avatar Eric de Ruiter avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.