Welcome nolan
, a comprehensive toolkit designed to enhance the development of Golang applications by providing a range of modules and utilities that streamline common programming tasks.
This library includes a variety of modules that offer functionalities such as:
- Data Manipulation: Tools for handling and transforming data structures.
- Concurrency Utilities: Enhancements for Go's native concurrency model, making goroutine management easier.
- Process Utilities: Easy-to-use modules for process scheduling and management.
To use this library, you need to have Go installed on your machine. You can install Go by following the instructions on the official Go website.
Install the library with the following Go command:
go get github.com/neutrinocorp/nolan
Here's a simple example of how to use a module from this library:
package main
import (
"fmt"
"github.com/neutrinocorp/nolan"
"github.com/neutrinocorp/nolan/collection/list"
"github.com/neutrinocorp/nolan/collection/queue"
)
func main() {
ls := list.NewDoublyLinkedList[int]()
ls.Add(1)
ls.Add(2)
ls.Add(3)
fmt.Println(ls.ToSlice())
deque := queue.NewDequeList[int](ls)
fmt.Println(deque.PollLast()) // 3
fmt.Println(deque.PollLast()) // 2
fmt.Println(deque.PollLast()) // 1
}
package main
import (
"context"
"log"
"time"
"github.com/neutrinocorp/nolan"
"github.com/neutrinocorp/nolan/collection/list"
"github.com/neutrinocorp/nolan/collection/queue"
"github.com/neutrinocorp/nolan/function"
"github.com/neutrinocorp/nolan/proc"
)
func main() {
var delegateFunc function.DelegateSafeFuncWithContext[string] = func(ctx context.Context, args string) error {
log.Printf("some args %s", args)
return nil
}
sched := proc.NewTaskScheduler[string](delegateFunc)
go func() {
if err := sched.Start(); err != nil {
panic(err)
}
}()
if err := sched.SubmitWork("some job"); err != nil {
panic(err) // this will return an error if the process is already closed
}
if err := sched.SubmitWork("some job"); err != nil {
panic(err)
}
// ... os.Stdout will print jobs as delegate will get executed
// execute graceful shutdown
ctx, cancelFunc := context.WithTimeout(context.Background(), time.Second * 30)
defer cancelFunc()
if err := sched.Stop(ctx); err != nil {
panic(err) // will return error if context reaches deadline before actual process termination (i.e., interrupted)
}
}
For more detailed documentation on each module and its functions, visit the Documentation section of this repository.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the Apache 2.0 License. See LICENSE
for more information.
Your Name - @neutrinocorp - [email protected]
Project Link: https://github.com/neuntrinocorp/nolan