Documentation ¶
Overview ¶
Package resource provides some means to deal with resources.
Index ¶
- func ClosableIOTransform[A any](cioca Closable[io.IO[Closable[A]]]) (ioca io.IO[Closable[A]])
- func Use[A any, B any](res Resource[A], f func(A) io.IO[B]) io.IO[B]
- type Closable
- type ClosableIO
- type Resource
- func BoundedExecutionContextResource(size int, queueLimit int) Resource[io.ExecutionContext]
- func Fail[A any](err error) Resource[A]
- func FlatMap[A any, B any](ra Resource[A], f func(a A) Resource[B]) Resource[B]
- func FromClosableIO[A ClosableIO](ioa io.IO[A]) Resource[A]
- func Map[A any, B any](ra Resource[A], f func(a A) B) Resource[B]
- func NewResource[A any](acquire io.IO[A], release func(A) io.IO[fun.Unit]) Resource[A]
- func NewResourceFromIOClosable[A any](cl io.IO[Closable[A]]) Resource[A]
- func UnbufferedChannel[A any]() Resource[chan A]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClosableIOTransform ¶
ClosableIOTransform transforms a closable of io closable to just io closable.
Types ¶
type Closable ¶
Closable is a value that is accompanied with the Close(). This is an internal structure that should not be used outside of the resource package.
func ClosableFlatMap ¶
ClosableFlatMap flatmaps the closable. Allows to construct have more than one resource in scope.
type ClosableIO ¶ added in v0.1.8
ClosableIO is a simple resource that implements Close method.
type Resource ¶
Resource[A] is an structure that can only be _used_ via Use. Unfortunately, it's not an interface, because interface methods do not support generics at the moment.
func BoundedExecutionContextResource ¶ added in v0.1.8
func BoundedExecutionContextResource(size int, queueLimit int) Resource[io.ExecutionContext]
BoundedExecutionContextResource returns a resource that is a bounded execution context.
func FlatMap ¶
FlatMap allows to add another resource to scope. Both will be released in reverse order.
func FromClosableIO ¶ added in v0.1.8
func FromClosableIO[A ClosableIO](ioa io.IO[A]) Resource[A]
FromClosableIO constructs a new resource from some value that itself supports method Close.
func NewResource ¶
NewResource constructs a resource given two functions - acquire and release.
func NewResourceFromIOClosable ¶
NewResourceFromIOClosable - is an internal function that constructs a resource from closable IO.
func UnbufferedChannel ¶ added in v0.1.0
UnbufferedChannel returns a resource that manages a channel.