Documentation
¶
Index ¶
- Variables
- func SetLogger(l *slog.Logger)
- type Pipeline
- func (p *Pipeline[T]) Build() (func(io.Reader) (T, error), func(T, io.Writer) error)
- func (p *Pipeline[T]) UseAsymmetricEncryption(publicKeyFn func() *rsa.PublicKey, privateKeyFn func() *rsa.PrivateKey) *Pipeline[T]
- func (p *Pipeline[T]) UseCompression() *Pipeline[T]
- func (p *Pipeline[T]) UseCustomOperation(readFn, writeFn func([]byte) ([]byte, error)) *Pipeline[T]
- func (p *Pipeline[T]) UseGobEncoding() *Pipeline[T]
- func (p *Pipeline[T]) UseJSONEncoding() *Pipeline[T]
- func (p *Pipeline[T]) UseNonce(set func() int, check func(int) bool) *Pipeline[T]
- func (p *Pipeline[T]) UseSigning(publicKeyFn func() *rsa.PublicKey, privateKeyFn func() *rsa.PrivateKey) *Pipeline[T]
- func (p *Pipeline[T]) UseTimeout(t time.Duration) *Pipeline[T]
- type ReadPipeline
- func (p *ReadPipeline[R]) Build() func(io.Reader) (R, error)
- func (p *ReadPipeline[R]) UseAsymmetricEncryption(privateKeyFn func() *rsa.PrivateKey) *ReadPipeline[R]
- func (p *ReadPipeline[R]) UseCompression() *ReadPipeline[R]
- func (p *ReadPipeline[R]) UseCustomOperation(readFn func([]byte) ([]byte, error)) *ReadPipeline[R]
- func (p *ReadPipeline[R]) UseGobEncoding() *ReadPipeline[R]
- func (p *ReadPipeline[R]) UseJSONEncoding() *ReadPipeline[R]
- func (p *ReadPipeline[R]) UseNonce(check func(int) bool) *ReadPipeline[R]
- func (p *ReadPipeline[R]) UseSigning(publicKeyFn func() *rsa.PublicKey) *ReadPipeline[R]
- func (p *ReadPipeline[R]) UseTimeout(t time.Duration) *ReadPipeline[R]
- type WritePipeline
- func (p *WritePipeline[W]) Build() func(W, io.Writer) error
- func (p *WritePipeline[W]) UseAsymmetricEncryption(publicKeyFn func() *rsa.PublicKey) *WritePipeline[W]
- func (p *WritePipeline[W]) UseCompression() *WritePipeline[W]
- func (p *WritePipeline[W]) UseCustomOperation(writeFn func([]byte) ([]byte, error)) *WritePipeline[W]
- func (p *WritePipeline[W]) UseGobEncoding() *WritePipeline[W]
- func (p *WritePipeline[W]) UseJSONEncoding() *WritePipeline[W]
- func (p *WritePipeline[W]) UseNonce(set func() int) *WritePipeline[W]
- func (p *WritePipeline[W]) UseSigning(privateKeyFn func() *rsa.PrivateKey) *WritePipeline[W]
- func (p *WritePipeline[W]) UseTimeout(t time.Duration) *WritePipeline[W]
Constants ¶
This section is empty.
Variables ¶
var ErrNonceInvalid = fmt.Errorf("nonce is invalid")
var ErrTimedOut = fmt.Errorf("operation timed out")
Functions ¶
Types ¶
type Pipeline ¶
type Pipeline[T any] struct { // contains filtered or unexported fields }
Represents a pipeline of read/write operations for any type T. The underlying operations act upon byte slices and return byte slices and error if one occured.
func New ¶
Creates a new empty pipeline with read and write pipelines underpinning it's operation.
This pipeline can be build and used immediately. By default, if no encoder has been selected, the Gob encoder will be used at build time.
func (*Pipeline[T]) Build ¶
Compiles the pipline into a read func and write func following the specification of the pipeline operations and selected encoders.
func (*Pipeline[T]) UseAsymmetricEncryption ¶
func (p *Pipeline[T]) UseAsymmetricEncryption(publicKeyFn func() *rsa.PublicKey, privateKeyFn func() *rsa.PrivateKey) *Pipeline[T]
Use RSA asymmetric encryption for encrypting and decrypting data.
It is up to the consumer of the library to provide callback functions that return the public and private keys. The functions will only be used during read and write operations, not during the building of the pipeline.
func (*Pipeline[T]) UseCompression ¶
Appends a compression step to the write operations and a decompression strep to the read operations.//
Compression is done with the `compress/zlib` library.
func (*Pipeline[T]) UseCustomOperation ¶
Custom Operations allow the consumer to define their own write and read operations to append to the pipeline.
Both functions take in a []byte and output a modified []byte or error. It is ok to return a new []byte or modify the existing one.
func (*Pipeline[T]) UseGobEncoding ¶
Enables on-boarding and off-boarding to the pipeline using Go's native Go Object Encoding.
Gob Encoding requires that structs export their fields to be transmitted. No exported fields will result in an error on write.
func (*Pipeline[T]) UseJSONEncoding ¶
Enables on-boarding and off-boarding to the pipeline using JSON Encoding.
func (*Pipeline[T]) UseNonce ¶
Enables the use of integer nonces in read and write operations. The provided nonce set and check functions are callbacks for how to generate the nonce for writing and how to check them upon reading.
func (*Pipeline[T]) UseSigning ¶
func (p *Pipeline[T]) UseSigning(publicKeyFn func() *rsa.PublicKey, privateKeyFn func() *rsa.PrivateKey) *Pipeline[T]
Use RSA asymmetric encryption for signing and verifying data being sent. The write operation to the pipeline appends a []byte containing the signature. The read operation will cut the signature from the pipeline, verify it, and either continue processing or error if the signature fails to validate.
It is up to the consumer of the library to provide callback functions that return the public and private keys. The functions will only be used during read and write operations, not during the building of the pipeline.
type ReadPipeline ¶
type ReadPipeline[R any] struct { // contains filtered or unexported fields }
Represents a pipeline of read operations for any type R. The underlying operations act upon byte slices and return byte slices and error if one occured.
func NewReadPipeline ¶
func NewReadPipeline[R any]() *ReadPipeline[R]
Creates a new empty pipeline supporting read operations.
This pipeline can be build and used immediately. By default, if no encoder has been selected, the Gob encoder will be used at build time.
func (*ReadPipeline[R]) Build ¶
func (p *ReadPipeline[R]) Build() func(io.Reader) (R, error)
Compiles the pipline into a read func following the specification of the pipeline operations and selected encoders.
func (*ReadPipeline[R]) UseAsymmetricEncryption ¶
func (p *ReadPipeline[R]) UseAsymmetricEncryption(privateKeyFn func() *rsa.PrivateKey) *ReadPipeline[R]
Use RSA asymmetric encryption for decrypting data.
It is up to the consumer of the library to provide a callback function to return the private key. The functions will only be used during read and write operations, not during the building of the pipeline.
func (*ReadPipeline[R]) UseCompression ¶
func (p *ReadPipeline[R]) UseCompression() *ReadPipeline[R]
Appends a decompression step to the read operations.
Compression is done with the `compress/zlib` library.
func (*ReadPipeline[R]) UseCustomOperation ¶
func (p *ReadPipeline[R]) UseCustomOperation(readFn func([]byte) ([]byte, error)) *ReadPipeline[R]
Custom Operations allow the consumer to define their own read operations to append to the pipeline.
Functions take in a []byte and output a modified []byte or error. It is ok to return a new []byte or modify the existing one.
func (*ReadPipeline[R]) UseGobEncoding ¶
func (p *ReadPipeline[R]) UseGobEncoding() *ReadPipeline[R]
Enables off-boarding from the pipeline using Go's native Go Object Encoding.
Gob Encoding requires that structs export their fields to be transmitted. No exported fields will result in an error on write.
func (*ReadPipeline[R]) UseJSONEncoding ¶
func (p *ReadPipeline[R]) UseJSONEncoding() *ReadPipeline[R]
Enables off-boarding from the pipeline using JSON Encoding.
func (*ReadPipeline[R]) UseNonce ¶
func (p *ReadPipeline[R]) UseNonce(check func(int) bool) *ReadPipeline[R]
Enables nonces during read operations. An integer nonce is checked for validity using the check callback during reading
func (*ReadPipeline[R]) UseSigning ¶
func (p *ReadPipeline[R]) UseSigning(publicKeyFn func() *rsa.PublicKey) *ReadPipeline[R]
Use RSA asymmetric encryption for verifying data being sent. The read operation will cut the signature from the pipeline, verify it, and either continue processing or error if the signature fails to validate.
It is up to the consumer of the library to provide callback functions that return the public key. The functions will only be used during read and write operations, not during the building of the pipeline.
func (*ReadPipeline[R]) UseTimeout ¶
func (p *ReadPipeline[R]) UseTimeout(t time.Duration) *ReadPipeline[R]
Enables a timeout on all operations. This timeout is used for each operation, as well as decoding final payloads.
type WritePipeline ¶
type WritePipeline[W any] struct { // contains filtered or unexported fields }
Represents a pipeline of write operations for any type W. The underlying operations act upon byte slices and return byte slices and error if one occured.
func NewWritePipeline ¶
func NewWritePipeline[W any]() *WritePipeline[W]
Creates a new empty pipeline supporting write operations.
This pipeline can be build and used immediately. By default, if no encoder has been selected, the Gob encoder will be used at build time.
func (*WritePipeline[W]) Build ¶
func (p *WritePipeline[W]) Build() func(W, io.Writer) error
Compiles the pipline into a read func and write func following the specification of the pipeline operations and selected encoders.
func (*WritePipeline[W]) UseAsymmetricEncryption ¶
func (p *WritePipeline[W]) UseAsymmetricEncryption(publicKeyFn func() *rsa.PublicKey) *WritePipeline[W]
Use RSA asymmetric encryption for encrypting data.
It is up to the consumer of the library to provide a callback function to return the public key. The function will only be used during write operations, not during the building of the pipeline.
func (*WritePipeline[W]) UseCompression ¶
func (p *WritePipeline[W]) UseCompression() *WritePipeline[W]
Appends a compression step to the write operations.
Compression is done with the `compress/zlib` library.
func (*WritePipeline[W]) UseCustomOperation ¶
func (p *WritePipeline[W]) UseCustomOperation(writeFn func([]byte) ([]byte, error)) *WritePipeline[W]
Custom Operations allow the consumer to define their own write operations to append to the pipeline.
Functions take in a []byte and output a modified []byte or error. It is ok to return a new []byte or modify the existing one.
func (*WritePipeline[W]) UseGobEncoding ¶
func (p *WritePipeline[W]) UseGobEncoding() *WritePipeline[W]
Enables on-boarding to the pipeline using Go's native Go Object Encoding.
Gob Encoding requires that structs export their fields to be transmitted. No exported fields will result in an error on write.
func (*WritePipeline[W]) UseJSONEncoding ¶
func (p *WritePipeline[W]) UseJSONEncoding() *WritePipeline[W]
Enables on-boarding to the pipeline using JSON Encoding.
func (*WritePipeline[W]) UseNonce ¶
func (p *WritePipeline[W]) UseNonce(set func() int) *WritePipeline[W]
Enables nonces during read operations. An integer nonce is checked for validity using the check callback during reading
func (*WritePipeline[W]) UseSigning ¶
func (p *WritePipeline[W]) UseSigning(privateKeyFn func() *rsa.PrivateKey) *WritePipeline[W]
Use RSA asymmetric encryption for signing the data being sent. The write operation to the pipeline appends a []byte containing the signature.
It is up to the consumer of the library to provide the callback function to return the private key. The function will only be used during write operations, not during the building of the pipeline.
func (*WritePipeline[W]) UseTimeout ¶
func (p *WritePipeline[W]) UseTimeout(t time.Duration) *WritePipeline[W]
Enables a timeout on all operations. This timeout is used for each operation, as well as encoding the initial payload.