common

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package common contains helper methods used by all store implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelSender

type ChannelSender struct {
	// contains filtered or unexported fields
}

ChannelSender sends data to a channel. See Write method for more details.

func NewChannelSender

func NewChannelSender(channel interface{}, unmarshal UnmarshalFunc, keySplitter func(string) []string) (*ChannelSender, error)

NewChannelSender creates a ChannelSender. The passed channel type must implmement the store.KeyOpSetter interface. Additionally, if the channel is a receive-only channel, an error is returned.

func (*ChannelSender) Send

func (w *ChannelSender) Send(key string, op store.Operation, data []byte) error

Send creates a new instance of the channel's type (which must implement store.KeyOpSetter interface see NewChannelSender) and applies SetKey and SetOp method.

If channel's type implements store.KeyMarshaller and keySplitter func is not nil, MarshalKey is applied on the splitted key. This can be useful for setting struct fields from key.

If data is not empty, it is unmarshaled into the newly created instance and sends the result on the channel.

type UnmarshalFunc

type UnmarshalFunc func(data []byte, v interface{}) error

UnmarshalFunc is a function that can unmarshal data to an object v.

Jump to

Keyboard shortcuts

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