store

package
v0.0.0-...-bd2fda9 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package store store all tasks

Example
package main

import (
	"context"
	"fmt"
	"time"

	"github.com/Laisky/go-ramjet/internal/tasks/store"
)

func bindTask() {
	fmt.Println("bind task")
	go store.TaskStore.Ticker(1*time.Second, taskRunner)
}

func taskRunner() {
	fmt.Println("running task")
}

func main() {
	// bind task binder
	store.TaskStore.Store("demo", bindTask)

	// start task binder
	go store.TaskStore.Start(context.Background())
}
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// TaskStore global tasks store
	TaskStore = &taskStoreType{
		bindFuncs:          []*task{},
		evtListeners:       &sync.Map{},
		tobeUnregisterTask: &sync.Map{},
		runChan:            make(chan func(), defaultRunChanSize),
		evtChan:            make(chan *Event, defaultEvtChanSize),
	}
)

Functions

This section is empty.

Types

type Event

type Event struct {
	Ts         time.Time
	Name, Type string
	Err        error
	Meta       map[string]interface{}
	Result     interface{}
}

Event can trigger registered handler

type EventListener

type EventListener func(*Event)

EventListener is the func to handle Event

Jump to

Keyboard shortcuts

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