|
1 | | -# nolan |
2 | | -Neutrino core libraries for Go |
| 1 | +# Nolan |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +This library includes a variety of modules that offer functionalities such as: |
| 8 | + |
| 9 | +- **Data Manipulation**: Tools for handling and transforming data structures. |
| 10 | +- **Concurrency Utilities**: Enhancements for Go's native concurrency model, making goroutine management easier. |
| 11 | +- **Process Utilities**: Easy-to-use modules for process scheduling and management. |
| 12 | + |
| 13 | +## Getting Started |
| 14 | + |
| 15 | +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](https://golang.org/dl/). |
| 16 | + |
| 17 | +### Installation |
| 18 | + |
| 19 | +Install the library with the following Go command: |
| 20 | + |
| 21 | +```bash |
| 22 | +go get github.com/neutrinocorp/nolan |
| 23 | +``` |
| 24 | + |
| 25 | +### Usage |
| 26 | + |
| 27 | +Here's a simple example of how to use a module from this library: |
| 28 | + |
| 29 | +#### Data Structures |
| 30 | + |
| 31 | +```go |
| 32 | +package main |
| 33 | + |
| 34 | +import ( |
| 35 | + "fmt" |
| 36 | + |
| 37 | + "github.com/neutrinocorp/nolan" |
| 38 | + "github.com/neutrinocorp/nolan/collection/list" |
| 39 | + "github.com/neutrinocorp/nolan/collection/queue" |
| 40 | +) |
| 41 | + |
| 42 | +func main() { |
| 43 | + ls := list.NewDoublyLinkedList[int]() |
| 44 | + ls.Add(1) |
| 45 | + ls.Add(2) |
| 46 | + ls.Add(3) |
| 47 | + fmt.Println(ls.ToSlice()) |
| 48 | + |
| 49 | + deque := queue.NewDequeList[int](ls) |
| 50 | + fmt.Println(deque.PollLast()) // 3 |
| 51 | + fmt.Println(deque.PollLast()) // 2 |
| 52 | + fmt.Println(deque.PollLast()) // 1 |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +#### Processing |
| 57 | + |
| 58 | +```go |
| 59 | +package main |
| 60 | + |
| 61 | +import ( |
| 62 | + "context" |
| 63 | + "log" |
| 64 | + "time" |
| 65 | + |
| 66 | + "github.com/neutrinocorp/nolan" |
| 67 | + "github.com/neutrinocorp/nolan/collection/list" |
| 68 | + "github.com/neutrinocorp/nolan/collection/queue" |
| 69 | + "github.com/neutrinocorp/nolan/function" |
| 70 | + "github.com/neutrinocorp/nolan/proc" |
| 71 | +) |
| 72 | + |
| 73 | +func main() { |
| 74 | + var delegateFunc function.DelegateSafeFuncWithContext[string] = func(ctx context.Context, args string) error { |
| 75 | + log.Printf("some args %s", args) |
| 76 | + return nil |
| 77 | + } |
| 78 | + |
| 79 | + sched := proc.NewTaskScheduler[string](delegateFunc) |
| 80 | + go func() { |
| 81 | + if err := sched.Start(); err != nil { |
| 82 | + panic(err) |
| 83 | + } |
| 84 | + }() |
| 85 | + |
| 86 | + if err := sched.SubmitWork("some job"); err != nil { |
| 87 | + panic(err) // this will return an error if the process is already closed |
| 88 | + } |
| 89 | + if err := sched.SubmitWork("some job"); err != nil { |
| 90 | + panic(err) |
| 91 | + } |
| 92 | + |
| 93 | + // ... os.Stdout will print jobs as delegate will get executed |
| 94 | + |
| 95 | + // execute graceful shutdown |
| 96 | + ctx, cancelFunc := context.WithTimeout(context.Background(), time.Second * 30) |
| 97 | + defer cancelFunc() |
| 98 | + if err := sched.Stop(ctx); err != nil { |
| 99 | + panic(err) // will return error if context reaches deadline before actual process termination (i.e., interrupted) |
| 100 | + } |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +## Documentation |
| 105 | + |
| 106 | +For more detailed documentation on each module and its functions, visit the [Documentation](https://github.com/neutrinocorp/nolan/wiki) section of this repository. |
| 107 | + |
| 108 | +## Contributing |
| 109 | + |
| 110 | +Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. |
| 111 | + |
| 112 | +1. Fork the Project |
| 113 | +2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) |
| 114 | +3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) |
| 115 | +4. Push to the Branch (`git push origin feature/AmazingFeature`) |
| 116 | +5. Open a Pull Request |
| 117 | + |
| 118 | +## License |
| 119 | + |
| 120 | +Distributed under the Apache 2.0 License. See `LICENSE` for more information. |
| 121 | + |
| 122 | +## Contact |
| 123 | + |
| 124 | +Your Name - [@neutrinocorp](https://twitter.com/neuntrinocorp) - oss@neutrinocorp.org |
| 125 | + |
| 126 | +Project Link: [https://github.com/neuntrinocorp/nolan](https://github.com/neuntrinocorp/nolan) |
0 commit comments