hazelcast

package module
Version: v1.0.0-preview.3 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 25 Imported by: 146

README


Note to Hazelcast Go Client for Hazelcast 3 Users

Support for Hazelcast 3.x ended on April 9th 2021, so Go client for Hazelcast 3 will not be updated. You can still use Go client for Hazelcast 3 by migrating your project to use Go modules and adding the following in your go.mod file:

require github.com/hazelcast/hazelcast-go-client v0.6.0

Note

The master branch is the development branch for the upcoming version 1 of the client. Version 1 is currently in alpha stage:

  • CODE IN THIS BRANCH IS IN NO WAY SUPPORTED FOR ANY PRODUCTION USE.
  • API IN THIS BRANCH CAN CHANGE IN BREAKING WAYS AT ANY TIME.

Your feedback and contribution are appreciated! Join us at Hazelcast Community Slack


Hazelcast Go Client

Hazelcast is an open-source distributed in-memory data store and computation platform that provides a wide variety of distributed data structures and concurrency primitives.

Hazelcast Go client is a way to communicate to Hazelcast IMDG clusters and access the cluster data.

Release Notes

1.0.0 Preview 3 (2021-06-08)

New features:

  • Set distributed data structure,

Changes:

  • When the client is not ready, it returns hazelcast.ErrClientNotActive instead of hazelcast.ErrClientNotReady.
  • serialization.ClassDefinition is public.

Improvements:

  • Memory utilization is improved and number of allocations are decreased.

1.0.0 Preview 2 (2021-05-21)

New features:

  • List distributed data structure,

Changes:

  • hazelcast.ConfigBuilder is removed. Use hazelcast.Config instead.
  • Signatures of serialization functions have changed to remove returned errors. If your serialization code needs to fail, simply panic. Panics are recovered and converted to errors.
  • hzerrors package is public.

Improvements:

  • Serialization performance is increased, especially for large payloads.
  • Memory utilization is improved and number of allocations are decreased.
  • Heartbeat service is enabled.

Fixes:

  • Fixed a regression introduced in Preview 1 which limited the message size to 8KBs.
  • Fixed Non-retryable errors.
  • Destroy function of DSSs removes corresponding proxies from the cache.

1.0.0 Preview 1 (2021-05-07)

The first preview release of the Hazelcast Go client has the following features:

Expect breaking changes in the following areas:

  • Configuration.
  • Map lock functions.

Sample Code

package main

import (
	"fmt"
	"log"

	"github.com/hazelcast/hazelcast-go-client"
)

func main() {
	// create the client and connect to the cluster
	client, err := hazelcast.StartNewClient() 
    if err != nil {
    	log.Fatal(err)
    }
    // get a map
    people, err := client.GetMap("people")
    if err != nil {
        log.Fatal(err)
    }
    personName := "Jane Doe"
    // set a value in the map
    if err = people.Set(personName, 30); err != nil {
    	log.Fatal(err)
    }
    // get a value from the map
    age, err := people.Get(personName)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%s is %d years old.\n", personName, age)
}

Features

  • Distributed, partitioned and queryable in-memory key-value store implementation, called Map.
  • Additional data structures and simple messaging constructs such as Replicated Map, Queue, List, and Topic.
  • Support for serverless and traditional web service architectures with Unisocket and Smart operation modes.
  • Ability to listen to client lifecycle, cluster state, and distributed data structure events.

Install

Requirements:

  • Hazelcast Go client is compatible only with Hazelcast IMDG 4.x and above.

In your Go module enabled project, add a dependency to github.com/hazelcast/hazelcast-go-client:

# Depend on a specific release
$ go get github.com/hazelcast/hazelcast-go-client@v1.0.0-preview.3

Quick Start

Hazelcast Go client requires a working Hazelcast IMDG cluster. This cluster handles the storage and manipulation of the user data.

A Hazelcast IMDG cluster consists of one or more cluster members. These members generally run on multiple virtual or physical machines and are connected to each other via the network. Any data put on the cluster is partitioned to multiple members transparent to the user. It is therefore very easy to scale the system by adding new members as the data grows. Hazelcast IMDG cluster also offers resilience. Should any hardware or software problem causes a crash to any member, the data on that member is recovered from backups and the cluster continues to operate without any downtime.

The quickest way to start a single member cluster for development purposes is to use our Docker images.

docker run --rm --name hazelcast -p 5701:5701 hazelcast/hazelcast:4.2

You can also use our ZIP or TAR distributions. After the download, you can start the Hazelcast member using the bin/start.sh script.

Starting the Default Client

Start the client with the default Hazelcast IMDG host and port using hazelcast.StartNewClient:

client, err := hazelcast.StartNewClient()
// handle client start error

Starting the Client with Given Options

Note that Config structs are not thread-safe. Complete creation of the configuration in a single go routine.

// create the default configuration
config := hazelcast.NewConfig()

// optionally set member addresses manually
config.ClusterConfig.SetAddress("member1.example.com", "member2.example.com")

// create and start the client with the configuration provider
client, err := hazelcast.StartNewClientWithConfig(config)
// handle client start error

Documentation

Use godoc:

$ godoc -http=localhost:5500

godoc is not installed by default with the base Go distribution. Install it using:

$ go get -u golang.org/x/tools/...`

Support

Join us at Go Client channel or Hazelcast at Google Groups.

Running the tests

Currently, we support only Linux, MacOS and WSL (Windows Subsystem for Linux) for testing the client.

You need to have the following installed in order to run integration tests:

  • Java 8
  • Maven 3 or better
  • Bash
  • Make

Before running the tests, starts Hazelcast Remote Controller, which enables the test suite to create clusters:

# Start RC with Hazelcast Community features
$ ./rc.sh start

# Or, start RC with Hazelcast Enterprise features
$ HAZELCAST_ENTERPRISE_KEY=ENTERPRISE-KEY-HERE ./rc.sh start 

You can run the tests using one of the following approaches:

  • Run make test-all to run integration tests.
  • Run make test-all-race to run integration tests with race detection.
  • Run make test-cover to generate the coverage report and make view-cover to view the test coverage summary and generate an HTML report.

Testing the client with SSL support requires running the remote controller with Hazelcast Enterprise features. To enable SSL connections, add ENABLE_SSL=1 to environment variables, or prepend it to the make commands above.

In order to turn on verbose logging, add ENABLE_TRACE=1 to environment variables, or prepend it to the make commands above.

License

Apache 2 License.

Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved.

Visit www.hazelcast.com for more information.

Documentation

Overview

Package hazelcast provides the Hazelcast Go client.

Example
// Create the configuration
config := hazelcast.NewConfig()
config.ClusterConfig.Name = "my-cluster"
if err := config.ClusterConfig.SetAddress("192.168.1.42:5000", "192.168.1.42:5001"); err != nil {
	log.Fatal(err)
}
// Start the client with the configuration provider.
client, err := hazelcast.StartNewClientWithConfig(config)
if err != nil {
	log.Fatal(err)
}
// Retrieve a map.
peopleMap, err := client.GetMap("people")
if err != nil {
	log.Fatal(err)
}
// Call map functions.
err = peopleMap.Set("jane", "doe")
if err != nil {
	log.Fatal(err)
}
// Stop the client once you are done with it.
client.Shutdown()
Output:

Index

Examples

Constants

View Source
const (
	// NotifyEntryAdded is dispatched if an entry is added.
	NotifyEntryAdded = int32(1 << 0)
	// NotifyEntryRemoved is dispatched if an entry is removed.
	NotifyEntryRemoved = int32(1 << 1)
	// NotifyEntryUpdated is dispatched if an entry is updated.
	NotifyEntryUpdated = int32(1 << 2)
	// NotifyEntryEvicted is dispatched if an entry is evicted.
	NotifyEntryEvicted = int32(1 << 3)
	// NotifyEntryExpired is dispatched if an entry is expired.
	NotifyEntryExpired = int32(1 << 4)
	// NotifyEntryAllEvicted is dispatched if all entries are evicted.
	NotifyEntryAllEvicted = int32(1 << 5)
	// NotifyEntryAllCleared is dispatched if all entries are cleared.
	NotifyEntryAllCleared = int32(1 << 6)
	// NotifyEntryMerged is dispatched if an entry is merged after a network partition.
	NotifyEntryMerged = int32(1 << 7)
	// NotifyEntryInvalidated is dispatched if an entry is invalidated.
	NotifyEntryInvalidated = int32(1 << 8)
	// NotifyEntryLoaded is dispatched if an entry is loaded.
	NotifyEntryLoaded = int32(1 << 9)
)
View Source
const (
	TtlDefault     = -1
	TtlUnlimited   = 0
	MaxIdleDefault = -1
)

Variables

View Source
var (
	ErrClientCannotStart = errors.New("client cannot start")
	ErrClientNotActive   = errors.New("client not active")
	ErrContextIsNil      = errors.New("context is nil")
)

Functions

This section is empty.

Types

type Client

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

func StartNewClient added in v1.0.0

func StartNewClient() (*Client, error)

StartNewClient creates and starts a new client. Hazelcast client enables you to do all Hazelcast operations without being a member of the cluster. It connects to one or more of the cluster members and delegates all cluster wide operations to them.

func StartNewClientWithConfig added in v1.0.0

func StartNewClientWithConfig(config Config) (*Client, error)

StartNewClientWithConfig creates and starts a new client with the given configuration. Hazelcast client enables you to do all Hazelcast operations without being a member of the cluster. It connects to one or more of the cluster members and delegates all cluster wide operations to them.

func (*Client) AddLifecycleListener added in v1.0.0

func (c *Client) AddLifecycleListener(handler LifecycleStateChangeHandler) (types.UUID, error)

AddLifecycleListener adds a lifecycle state change handler after the client starts. The listener is attached to the client after the client starts, so lifecyle events after the client start can be received. Use the returned subscription ID to remove the listener. The handler must not block.

func (*Client) AddMembershipListener added in v1.0.0

func (c *Client) AddMembershipListener(handler cluster.MembershipStateChangeHandler) (types.UUID, error)

AddMembershipListener adds a member state change handler with a unique subscription ID. The listener is attached to the client after the client starts, so membership events after the client start can be received. Use the returned subscription ID to remove the listener.

func (*Client) GetList

func (c *Client) GetList(name string) (*List, error)

GetList returns a list instance.

func (*Client) GetMap

func (c *Client) GetMap(name string) (*Map, error)

GetMap returns a distributed map instance.

func (*Client) GetQueue

func (c *Client) GetQueue(name string) (*Queue, error)

GetQueue returns a queue instance.

func (*Client) GetReplicatedMap

func (c *Client) GetReplicatedMap(name string) (*ReplicatedMap, error)

GetReplicatedMap returns a replicated map instance.

func (*Client) GetSet

func (c *Client) GetSet(name string) (*Set, error)

GetSet returns a set instance.

func (*Client) GetTopic

func (c *Client) GetTopic(name string) (*Topic, error)

GetTopic returns a topic instance.

func (*Client) Name

func (c *Client) Name() string

Name returns client's name Use ConfigBuilder.SetName to set the client name. If not set manually, an automatic name is used.

func (*Client) RemoveLifecycleListener added in v1.0.0

func (c *Client) RemoveLifecycleListener(subscriptionID types.UUID) error

RemoveLifecycleListener removes the lifecycle state change handler with the given subscription ID

func (*Client) RemoveMembershipListener added in v1.0.0

func (c *Client) RemoveMembershipListener(subscriptionID types.UUID) error

RemoveMembershipListener removes the member state change handler with the given subscription ID.

func (*Client) Running added in v1.0.0

func (c *Client) Running() bool

Running checks whether or not the client is running.

func (*Client) Shutdown

func (c *Client) Shutdown() error

Shutdown disconnects the client from the cluster.

type Config added in v1.0.0

type Config struct {
	ClientName          string
	LoggerConfig        logger.Config
	SerializationConfig serialization.Config
	ClusterConfig       cluster.Config
	// contains filtered or unexported fields
}

Config contains configuration for a client. Prefer to create the configuration using the NewConfig function.

func NewConfig

func NewConfig() Config

func (*Config) AddLifecycleListener added in v1.0.0

func (c *Config) AddLifecycleListener(handler LifecycleStateChangeHandler) types.UUID

AddLifecycleListener adds a lifecycle listener. The listener is attached to the client before the client starts, so all lifecycle events can be received. Use the returned subscription ID to remove the listener. The handler must not block.

func (*Config) AddMembershipListener added in v1.0.0

func (c *Config) AddMembershipListener(handler cluster.MembershipStateChangeHandler) types.UUID

AddMembershipListener adds a membership listeener. The listener is attached to the client before the client starts, so all membership events can be received. Use the returned subscription ID to remove the listener.

func (Config) Clone added in v1.0.0

func (c Config) Clone() Config

func (Config) Validate added in v1.0.0

func (c Config) Validate() error

type EntryNotified added in v1.0.0

type EntryNotified struct {
	MergingValue            interface{}
	Member                  cluster.Member
	Key                     interface{}
	Value                   interface{}
	OldValue                interface{}
	MapName                 string
	NumberOfAffectedEntries int
	EventType               int32
}

func (*EntryNotified) EventName added in v1.0.0

func (e *EntryNotified) EventName() string

type EntryNotifiedHandler added in v1.0.0

type EntryNotifiedHandler func(event *EntryNotified)

type IndexValidationError

type IndexValidationError struct {
	Err error
}

func (IndexValidationError) Error

func (ic IndexValidationError) Error() string

type ItemEventType added in v1.0.0

type ItemEventType int32

ItemEventType describes event types for item related events.

const (
	// NotifyItemAdded stands for item added event.
	NotifyItemAdded ItemEventType = 1
	// NotifyItemRemoved stands for item removed event.
	NotifyItemRemoved ItemEventType = 2
)

type LifecycleState added in v1.0.0

type LifecycleState int
const (
	// LifecycleStateStarting signals that the client is starting.
	LifecycleStateStarting LifecycleState = iota
	// LifecycleStateStarted signals that the client started.
	LifecycleStateStarted
	// LifecycleStateShuttingDown signals that the client is shutting down.
	LifecycleStateShuttingDown
	// LifecycleStateShutDown signals that the client shut down.
	LifecycleStateShutDown
	// LifecycleStateClientConnected signals that the client connected to the cluster.
	LifecycleStateClientConnected
	// LifecycleStateClientDisconnected signals that the client disconnected from the cluster.
	LifecycleStateClientDisconnected
)

type LifecycleStateChangeHandler added in v1.0.0

type LifecycleStateChangeHandler func(event LifecycleStateChanged)

type LifecycleStateChanged added in v1.0.0

type LifecycleStateChanged struct {
	State LifecycleState
}

func (*LifecycleStateChanged) EventName added in v1.0.0

func (e *LifecycleStateChanged) EventName() string

type List added in v1.0.0

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

List is a concurrent, distributed, ordered collection. The user of this data structure has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list.

List is not a partitioned Hazelcast data structure. So all the contents of the List are stored in a single machine (and in the backup). So, a single List will not scale by adding more members in the cluster.

func (*List) Add added in v1.0.0

func (l *List) Add(element interface{}) (bool, error)

Add appends the specified element to the end of this list. Returns true if the list has changed as a result of this operation, false otherwise.

func (*List) AddAll added in v1.0.0

func (l *List) AddAll(elements ...interface{}) (bool, error)

AddAll appends all elements in the specified slice to the end of this list. Returns true if the list has changed as a result of this operation, false otherwise.

func (*List) AddAllAt added in v1.0.0

func (l *List) AddAllAt(index int, elements ...interface{}) (bool, error)

AddAllAt inserts all elements in the specified slice at specified index, keeping the order of the slice. Shifts the subsequent elements to the right. Returns true if the list has changed as a result of this operation, false otherwise.

func (*List) AddAt added in v1.0.0

func (l *List) AddAt(index int, element interface{}) error

AddAt inserts the specified element at the specified index. Shifts the subsequent elements to the right.

func (*List) AddListener added in v1.0.0

func (l *List) AddListener(handler ListItemNotifiedHandler) (types.UUID, error)

AddListener adds an item listener for this list. The listener will be invoked whenever an item is added to or removed from this list. Returns subscription ID of the listener.

func (*List) AddListenerIncludeValue

func (l *List) AddListenerIncludeValue(handler ListItemNotifiedHandler) (types.UUID, error)

AddListener adds an item listener for this list. The listener will be invoked whenever an item is added to or removed from this list. Received events include the updated item. Returns subscription ID of the listener.

func (*List) Clear added in v1.0.0

func (l *List) Clear() error

Clear removes all elements from the list.

func (*List) Contains added in v1.0.0

func (l *List) Contains(element interface{}) (bool, error)

Contains checks if the list contains the given element. Returns true if the list contains the element, false otherwise.

func (*List) ContainsAll added in v1.0.0

func (l *List) ContainsAll(elements ...interface{}) (bool, error)

ContainsAll checks if the list contains all of the given elements. Returns true if the list contains all of the elements, otherwise false.

func (List) Destroy added in v1.0.0

func (p List) Destroy() error

Destroys this object cluster-wide. Clears and releases all resources for this object.

func (*List) Get added in v1.0.0

func (l *List) Get(index int) (interface{}, error)

Get retrieves the element at given index.

func (*List) IndexOf added in v1.0.0

func (l *List) IndexOf(element interface{}) (int, error)

IndexOf returns the index of the first occurrence of the given element in this list.

func (*List) IsEmpty added in v1.0.0

func (l *List) IsEmpty() (bool, error)

IsEmpty return true if the list is empty, false otherwise.

func (*List) LastIndexOf added in v1.0.0

func (l *List) LastIndexOf(element interface{}) (int, error)

LastIndexOf returns the index of the last occurrence of the given element in this list.

func (*List) Remove added in v1.0.0

func (l *List) Remove(element interface{}) (bool, error)

Remove removes the given element from this list. Returns true if the list has changed as the result of this operation, false otherwise.

func (*List) RemoveAll added in v1.0.0

func (l *List) RemoveAll(elements ...interface{}) (bool, error)

RemoveAll removes the given elements from the list. Returns true if the list has changed as the result of this operation, false otherwise.

func (*List) RemoveAt added in v1.0.0

func (l *List) RemoveAt(index int) (interface{}, error)

RemoveAt removes the element at the given index. Returns the removed element.

func (*List) RemoveListener added in v1.0.0

func (l *List) RemoveListener(subscriptionID types.UUID) error

RemoveListener removes the item listener with the given subscription ID.

func (*List) RetainAll added in v1.0.0

func (l *List) RetainAll(elements ...interface{}) (bool, error)

RetainAll removes all elements from this list except the ones contained in the given slice. Returns true if the list has changed as a result of this operation, false otherwise.

func (*List) Set added in v1.0.0

func (l *List) Set(index int, element interface{}) (interface{}, error)

Set replaces the element at the specified index in this list with the specified element. Returns the previous element from the list.

func (*List) Size added in v1.0.0

func (l *List) Size() (int, error)

Size returns the number of elements in this list.

func (*List) SubList added in v1.0.0

func (l *List) SubList(start int, end int) ([]interface{}, error)

SubList returns a view of this list that contains elements between index numbers from start (inclusive) to end (exclusive).

func (*List) ToSlice

func (l *List) ToSlice() ([]interface{}, error)

ToSlice returns a slice that contains all elements of this list in proper sequence.

type ListItemNotified added in v1.0.0

type ListItemNotified struct {
	Value     interface{}
	Member    cluster.Member
	ListName  string
	EventType ItemEventType
}

ListItemNotified describes the List item event.

func (ListItemNotified) EventName added in v1.0.0

func (q ListItemNotified) EventName() string

EventName returns generic event name, common for all List item listeners.

type ListItemNotifiedHandler added in v1.0.0

type ListItemNotifiedHandler func(event *ListItemNotified)

ListItemNotifiedHandler is a handler function for the List item listener.

type Map added in v1.0.0

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

func (*Map) AddEntryListener added in v1.0.0

func (m *Map) AddEntryListener(config MapEntryListenerConfig, handler EntryNotifiedHandler) (types.UUID, error)

AddEntryListener adds a continuous entry listener to this map.

func (*Map) AddIndexWithConfig

func (m *Map) AddIndexWithConfig(indexConfig types.IndexConfig) error

AddIndexWithConfig adds an index to this map for the specified entries so that queries can run faster.

func (*Map) AddInterceptor added in v1.0.0

func (m *Map) AddInterceptor(interceptor interface{}) (string, error)

AddInterceptor adds an interceptor for this map.

func (*Map) Clear added in v1.0.0

func (m *Map) Clear() error

Clear deletes all entries one by one and fires related events

func (*Map) ContainsKey added in v1.0.0

func (m *Map) ContainsKey(key interface{}) (bool, error)

ContainsKey returns true if the map contains an entry with the given key

func (*Map) ContainsValue added in v1.0.0

func (m *Map) ContainsValue(value interface{}) (bool, error)

ContainsValue returns true if the map contains an entry with the given value

func (*Map) Delete added in v1.0.0

func (m *Map) Delete(key interface{}) error

Delete removes the mapping for a key from this map if it is present Unlike remove(object), this operation does not return the removed value, which avoids the serialization cost of the returned value. If the removed value will not be used, a delete operation is preferred over a remove operation for better performance.

func (Map) Destroy added in v1.0.0

func (p Map) Destroy() error

Destroys this object cluster-wide. Clears and releases all resources for this object.

func (*Map) Evict added in v1.0.0

func (m *Map) Evict(key interface{}) (bool, error)

Evict evicts the mapping for a key from this map. Returns true if the key is evicted.

func (*Map) EvictAll added in v1.0.0

func (m *Map) EvictAll() error

EvictAll deletes all entries withour firing releated events

func (*Map) ExecuteOnEntries added in v1.0.0

func (m *Map) ExecuteOnEntries(entryProcessor interface{}) ([]types.Entry, error)

ExecuteOnEntries applies the user defined EntryProcessor to all the entries in the map.

func (*Map) Flush added in v1.0.0

func (m *Map) Flush() error

Flush flushes all the local dirty entries.

func (*Map) ForceUnlock added in v1.0.0

func (m *Map) ForceUnlock(key interface{}) error

ForceUnlock releases the lock for the specified key regardless of the lock owner. It always successfully unlocks the key, never blocks, and returns immediately.

func (*Map) Get added in v1.0.0

func (m *Map) Get(key interface{}) (interface{}, error)

Get returns the value for the specified key, or nil if this map does not contain this key. Warning: This method returns a clone of original value, modifying the returned value does not change the actual value in the map. One should put modified value back to make changes visible to all nodes.

func (*Map) GetAll added in v1.0.0

func (m *Map) GetAll(keys ...interface{}) ([]types.Entry, error)

GetAll returns the entries for the given keys.

func (*Map) GetEntrySet added in v1.0.0

func (m *Map) GetEntrySet() ([]types.Entry, error)

GetEntrySet returns a clone of the mappings contained in this map.

func (*Map) GetEntrySetWithPredicate added in v1.0.0

func (m *Map) GetEntrySetWithPredicate(predicate predicate.Predicate) ([]types.Entry, error)

GetEntrySetWithPredicate returns a clone of the mappings contained in this map.

func (*Map) GetEntryView added in v1.0.0

func (m *Map) GetEntryView(key string) (*types.SimpleEntryView, error)

GetEntryView returns the SimpleEntryView for the specified key.

func (*Map) GetKeySet added in v1.0.0

func (m *Map) GetKeySet() ([]interface{}, error)

GetKeySet returns keys contained in this map

func (*Map) GetKeySetWithPredicate added in v1.0.0

func (m *Map) GetKeySetWithPredicate(predicate predicate.Predicate) ([]interface{}, error)

GetKeySetWithPredicate returns keys contained in this map

func (*Map) GetValues added in v1.0.0

func (m *Map) GetValues() ([]interface{}, error)

GetValues returns a list clone of the values contained in this map

func (*Map) GetValuesWithPredicate added in v1.0.0

func (m *Map) GetValuesWithPredicate(predicate predicate.Predicate) ([]interface{}, error)

GetValuesWithPredicate returns a list clone of the values contained in this map

func (*Map) IsEmpty added in v1.0.0

func (m *Map) IsEmpty() (bool, error)

IsEmpty returns true if this map contains no key-value mappings.

func (*Map) IsLocked added in v1.0.0

func (m *Map) IsLocked(key interface{}) (bool, error)

IsLocked checks the lock for the specified key.

func (*Map) LoadAllReplacing added in v1.0.0

func (m *Map) LoadAllReplacing(keys ...interface{}) error

LoadAllReplacing loads all keys from the store at server side or loads the given keys if provided. Replaces existing keys.

func (*Map) LoadAllWithoutReplacing added in v1.0.0

func (m *Map) LoadAllWithoutReplacing(keys ...interface{}) error

LoadAllWithoutReplacing loads all keys from the store at server side or loads the given keys if provided.

func (*Map) Lock added in v1.0.0

func (m *Map) Lock(key interface{}) error

Lock acquires the lock for the specified key infinitely or for the specified lease time if provided. If the lock is not available, the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.

You get a lock whether the value is present in the map or not. Other threads (possibly on other systems) would block on their invoke of lock() until the non-existent key is unlocked. If the lock holder introduces the key to the map, the put() operation is not blocked. If a thread not holding a lock on the non-existent key tries to introduce the key while a lock exists on the non-existent key, the put() operation blocks until it is unlocked.

Scope of the lock is this map only. Acquired lock is only for the key in this map.

Locks are re-entrant; so, if the key is locked N times, it should be unlocked N times before another thread can acquire it.

func (*Map) LockWithLease added in v1.0.0

func (m *Map) LockWithLease(key interface{}, leaseTime time.Duration) error

LockWithLease acquires the lock for the specified key infinitely or for the specified lease time if provided. If the lock is not available, the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.

You get a lock whether the value is present in the map or not. Other threads (possibly on other systems) would block on their invoke of lock() until the non-existent key is unlocked. If the lock holder introduces the key to the map, the put() operation is not blocked. If a thread not holding a lock on the non-existent key tries to introduce the key while a lock exists on the non-existent key, the put() operation blocks until it is unlocked.

Scope of the lock is this map only. Acquired lock is only for the key in this map.

Locks are re-entrant; so, if the key is locked N times, it should be unlocked N times before another thread can acquire it. Lease time is the the time to wait before releasing the lock.

func (*Map) Put added in v1.0.0

func (m *Map) Put(key interface{}, value interface{}) (interface{}, error)

Put sets the value for the given key and returns the old value.

func (*Map) PutAll added in v1.0.0

func (m *Map) PutAll(keyValuePairs []types.Entry) error

PutAll copies all of the mappings from the specified map to this map. No atomicity guarantees are given. In the case of a failure, some of the key-value tuples may get written, while others are not.

func (*Map) PutIfAbsent added in v1.0.0

func (m *Map) PutIfAbsent(key interface{}, value interface{}) (interface{}, error)

PutIfAbsent associates the specified key with the given value if it is not already associated.

func (*Map) PutIfAbsentWithTTL added in v1.0.0

func (m *Map) PutIfAbsentWithTTL(key interface{}, value interface{}, ttl time.Duration) (interface{}, error)

PutIfAbsentWithTTL associates the specified key with the given value if it is not already associated. Entry will expire and get evicted after the ttl.

func (*Map) PutIfAbsentWithTTLAndMaxIdle added in v1.0.0

func (m *Map) PutIfAbsentWithTTLAndMaxIdle(key interface{}, value interface{}, ttl time.Duration, maxIdle time.Duration) (interface{}, error)

PutIfAbsentWithTTLAndMaxIdle associates the specified key with the given value if it is not already associated. Entry will expire and get evicted after the ttl. Given max idle time (maximum time for this entry to stay idle in the map) is used.

func (*Map) PutTransient added in v1.0.0

func (m *Map) PutTransient(key interface{}, value interface{}) error

PutTransient sets the value for the given key. MapStore defined at the server side will not be called. The TTL defined on the server-side configuration will be used. Max idle time defined on the server-side configuration will be used.

func (*Map) PutTransientWithMaxIdle added in v1.0.0

func (m *Map) PutTransientWithMaxIdle(key interface{}, value interface{}, maxIdle time.Duration) error

PutTransientWithMaxIdle sets the value for the given key. MapStore defined at the server side will not be called. Given max idle time (maximum time for this entry to stay idle in the map) is used. Set maxIdle to 0 for infinite idle time.

func (*Map) PutTransientWithTTL added in v1.0.0

func (m *Map) PutTransientWithTTL(key interface{}, value interface{}, ttl time.Duration) error

PutTransientWithTTL sets the value for the given key. MapStore defined at the server side will not be called. Given TTL (maximum time in seconds for this entry to stay in the map) is used. Set ttl to 0 for infinite timeout.

func (*Map) PutTransientWithTTLAndMaxIdle added in v1.0.0

func (m *Map) PutTransientWithTTLAndMaxIdle(key interface{}, value interface{}, ttl time.Duration, maxIdle time.Duration) error

PutTransientWithTTLAndMaxIdle sets the value for the given key. MapStore defined at the server side will not be called. Given TTL (maximum time in seconds for this entry to stay in the map) is used. Set ttl to 0 for infinite timeout. Given max idle time (maximum time for this entry to stay idle in the map) is used. Set maxIdle to 0 for infinite idle time.

func (*Map) PutWithMaxIdle added in v1.0.0

func (m *Map) PutWithMaxIdle(key interface{}, value interface{}, maxIdle time.Duration) (interface{}, error)

PutWithMaxIdle sets the value for the given key and returns the old value. maxIdle is the maximum time in seconds for this entry to stay idle in the map.

func (*Map) PutWithTTL added in v1.0.0

func (m *Map) PutWithTTL(key interface{}, value interface{}, ttl time.Duration) (interface{}, error)

PutWithTTL sets the value for the given key and returns the old value. Entry will expire and get evicted after the ttl.

func (*Map) PutWithTTLAndMaxIdle added in v1.0.0

func (m *Map) PutWithTTLAndMaxIdle(key interface{}, value interface{}, ttl time.Duration, maxIdle time.Duration) (interface{}, error)

PutWithTTLAndMaxIdle sets the value for the given key and returns the old value. Entry will expire and get evicted after the ttl. maxIdle is the maximum time in seconds for this entry to stay idle in the map.

func (*Map) Remove added in v1.0.0

func (m *Map) Remove(key interface{}) (interface{}, error)

Remove deletes the value for the given key and returns it.

func (*Map) RemoveAll added in v1.0.0

func (m *Map) RemoveAll(predicate predicate.Predicate) error

RemoveAll deletes all entries matching the given predicate.

func (*Map) RemoveEntryListener added in v1.0.0

func (m *Map) RemoveEntryListener(subscriptionID types.UUID) error

RemoveEntryListener removes the specified entry listener.

func (*Map) RemoveIfSame added in v1.0.0

func (m *Map) RemoveIfSame(key interface{}, value interface{}) (bool, error)

RemoveIfSame removes the entry for a key only if it is currently mapped to a given value. Returns true if the entry was removed.

func (*Map) RemoveInterceptor added in v1.0.0

func (m *Map) RemoveInterceptor(registrationID string) (bool, error)

RemoveInterceptor removes the interceptor.

func (*Map) Replace added in v1.0.0

func (m *Map) Replace(key interface{}, value interface{}) (interface{}, error)

Replace replaces the entry for a key only if it is currently mapped to some value and returns the previous value.

func (*Map) ReplaceIfSame added in v1.0.0

func (m *Map) ReplaceIfSame(key interface{}, oldValue interface{}, newValue interface{}) (bool, error)

ReplaceIfSame replaces the entry for a key only if it is currently mapped to a given value. Returns true if the value was replaced.

func (*Map) Set added in v1.0.0

func (m *Map) Set(key interface{}, value interface{}) error

Set sets the value for the given key.

func (*Map) SetTTL added in v1.0.0

func (m *Map) SetTTL(key interface{}, ttl time.Duration) error

SetTTL updates the TTL value of the entry specified by the given key with a new TTL value. Given TTL (maximum time in seconds for this entry to stay in the map) is used. Set ttl to 0 for infinite timeout.

func (*Map) SetWithTTL added in v1.0.0

func (m *Map) SetWithTTL(key interface{}, value interface{}, ttl time.Duration) error

SetWithTTL sets the value for the given key. Given TTL (maximum time in seconds for this entry to stay in the map) is used. Set ttl to 0 for infinite timeout.

func (*Map) SetWithTTLAndMaxIdle added in v1.0.0

func (m *Map) SetWithTTLAndMaxIdle(key interface{}, value interface{}, ttl time.Duration, maxIdle time.Duration) error

SetWithTTLAndMaxIdle sets the value for the given key. Given TTL (maximum time in seconds for this entry to stay in the map) is used. Set ttl to 0 for infinite timeout. Given max idle time (maximum time for this entry to stay idle in the map) is used. Set maxIdle to 0 for infinite idle time.

func (*Map) Size added in v1.0.0

func (m *Map) Size() (int, error)

Size returns the number of entries in this map.

func (*Map) TryLock added in v1.0.0

func (m *Map) TryLock(key interface{}) (bool, error)

TryLock tries to acquire the lock for the specified key. When the lock is not available, the current thread doesn't wait and returns false immediately.

func (*Map) TryLockWithLease added in v1.0.0

func (m *Map) TryLockWithLease(key interface{}, lease time.Duration) (bool, error)

TryLockWithLease tries to acquire the lock for the specified key. Lock will be released after lease time passes.

func (*Map) TryLockWithLeaseTimeout

func (m *Map) TryLockWithLeaseTimeout(key interface{}, lease time.Duration, timeout time.Duration) (bool, error)

TryLockWithLeaseTimeout tries to acquire the lock for the specified key. The current thread becomes disabled for thread scheduling purposes and lies dormant until one of the followings happens: - The lock is acquired by the current thread, or - The specified waiting time elapses. Lock will be released after lease time passes.

func (*Map) TryLockWithTimeout added in v1.0.0

func (m *Map) TryLockWithTimeout(key interface{}, timeout time.Duration) (bool, error)

TryLockWithTimeout tries to acquire the lock for the specified key. The current thread becomes disabled for thread scheduling purposes and lies dormant until one of the followings happens: - The lock is acquired by the current thread, or - The specified waiting time elapses.

func (*Map) TryPut added in v1.0.0

func (m *Map) TryPut(key interface{}, value interface{}) (bool, error)

TryPut tries to put the given key and value into this map and returns immediately.

func (*Map) TryPutWithTimeout added in v1.0.0

func (m *Map) TryPutWithTimeout(key interface{}, value interface{}, timeout time.Duration) (bool, error)

TryPut tries to put the given key and value into this map and waits until operation is completed or timeout is reached.

func (*Map) TryRemove added in v1.0.0

func (m *Map) TryRemove(key interface{}) (interface{}, error)

TryRemove tries to remove the given key from this map and returns immediately.

func (*Map) TryRemoveWithTimeout added in v1.0.0

func (m *Map) TryRemoveWithTimeout(key interface{}, timeout time.Duration) (interface{}, error)

TryRemoveWithTimeout tries to remove the given key from this map and waits until operation is completed or timeout is reached.

func (*Map) Unlock added in v1.0.0

func (m *Map) Unlock(key interface{}) error

Unlock releases the lock for the specified key.

type MapEntryListenerConfig added in v1.0.0

type MapEntryListenerConfig struct {
	Predicate predicate.Predicate
	Key       interface{}

	IncludeValue bool
	// contains filtered or unexported fields
}

func (*MapEntryListenerConfig) NotifyEntryAdded added in v1.0.0

func (c *MapEntryListenerConfig) NotifyEntryAdded(enable bool)

func (*MapEntryListenerConfig) NotifyEntryAllCleared added in v1.0.0

func (c *MapEntryListenerConfig) NotifyEntryAllCleared(enable bool)

func (*MapEntryListenerConfig) NotifyEntryAllEvicted added in v1.0.0

func (c *MapEntryListenerConfig) NotifyEntryAllEvicted(enable bool)

func (*MapEntryListenerConfig) NotifyEntryEvicted added in v1.0.0

func (c *MapEntryListenerConfig) NotifyEntryEvicted(enable bool)

func (*MapEntryListenerConfig) NotifyEntryExpired added in v1.0.0

func (c *MapEntryListenerConfig) NotifyEntryExpired(enable bool)

func (*MapEntryListenerConfig) NotifyEntryInvalidated added in v1.0.0

func (c *MapEntryListenerConfig) NotifyEntryInvalidated(enable bool)

func (*MapEntryListenerConfig) NotifyEntryLoaded added in v1.0.0

func (c *MapEntryListenerConfig) NotifyEntryLoaded(enable bool)

func (*MapEntryListenerConfig) NotifyEntryMerged added in v1.0.0

func (c *MapEntryListenerConfig) NotifyEntryMerged(enable bool)

func (*MapEntryListenerConfig) NotifyEntryRemoved added in v1.0.0

func (c *MapEntryListenerConfig) NotifyEntryRemoved(enable bool)

func (*MapEntryListenerConfig) NotifyEntryUpdated added in v1.0.0

func (c *MapEntryListenerConfig) NotifyEntryUpdated(enable bool)

type MessagePublished added in v1.0.0

type MessagePublished struct {
	PublishTime time.Time
	Value       interface{}
	Member      cluster.Member
	TopicName   string
}

func (*MessagePublished) EventName added in v1.0.0

func (m *MessagePublished) EventName() string

type Queue added in v1.0.0

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

Queue is a concurrent, blocking, distributed, observable queue.

Queue is not a partitioned data-structure. All of the Queue content is stored in a single machine (and in the backup). Queue will not scale by adding more members in the cluster.

func (*Queue) Add added in v1.0.0

func (q *Queue) Add(value interface{}) (bool, error)

Add adds the specified item to this queue if there is available space. Returns true when element is successfully added

func (*Queue) AddAll added in v1.0.0

func (q *Queue) AddAll(values ...interface{}) (bool, error)

AddAll adds the elements in the specified collection to this queue. Returns true if the queue is changed after the call.

func (*Queue) AddListener

func (q *Queue) AddListener(handler QueueItemNotifiedHandler) (types.UUID, error)

AddListener adds an item listener for this queue. Listener will be notified for all queue add/remove events.

func (*Queue) AddListenerIncludeValue

func (q *Queue) AddListenerIncludeValue(handler QueueItemNotifiedHandler) (types.UUID, error)

AddListenerIncludeValue adds an item listener for this queue. Listener will be notified for all queue add/remove events. Received events include the updated item.

func (*Queue) AddWithTimeout added in v1.0.0

func (q *Queue) AddWithTimeout(value interface{}, timeout time.Duration) (bool, error)

AddWithTimeout adds the specified item to this queue if there is available space. Returns true when element is successfully added

func (*Queue) Clear added in v1.0.0

func (q *Queue) Clear() error

Clear Clear this queue. Queue will be empty after this call.

func (*Queue) Contains added in v1.0.0

func (q *Queue) Contains(value interface{}) (bool, error)

Contains returns true if the queue includes the given value.

func (*Queue) ContainsAll added in v1.0.0

func (q *Queue) ContainsAll(values ...interface{}) (bool, error)

ContainsAll returns true if the queue includes all given values.

func (Queue) Destroy added in v1.0.0

func (p Queue) Destroy() error

Destroys this object cluster-wide. Clears and releases all resources for this object.

func (*Queue) Drain added in v1.0.0

func (q *Queue) Drain() ([]interface{}, error)

Drain returns all items in the queue and empties it.

func (*Queue) DrainWithMaxSize added in v1.0.0

func (q *Queue) DrainWithMaxSize(maxSize int) ([]interface{}, error)

DrainWithMaxSize returns maximum maxSize items in tne queue and removes returned items from the queue.

func (*Queue) IsEmpty added in v1.0.0

func (q *Queue) IsEmpty() (bool, error)

IsEmpty returns true if the queue is empty.

func (*Queue) Iterator

func (q *Queue) Iterator() ([]interface{}, error)

Iterator returns all of the items in this queue.

func (*Queue) Peek added in v1.0.0

func (q *Queue) Peek() (interface{}, error)

Peek retrieves the head of queue without removing it from the queue.

func (*Queue) Poll added in v1.0.0

func (q *Queue) Poll() (interface{}, error)

Poll retrieves and removes the head of this queue.

func (*Queue) PollWithTimeout added in v1.0.0

func (q *Queue) PollWithTimeout(timeout time.Duration) (interface{}, error)

PollWithTimeout retrieves and removes the head of this queue. Waits until this timeout elapses and returns the result.

func (*Queue) Put added in v1.0.0

func (q *Queue) Put(value interface{}) error

Put adds the specified element into this queue. If there is no space, it waits until necessary space becomes available.

func (*Queue) RemainingCapacity added in v1.0.0

func (q *Queue) RemainingCapacity() (int, error)

RemainingCapacity returns the remaining capacity of this queue.

func (*Queue) Remove added in v1.0.0

func (q *Queue) Remove(value interface{}) (bool, error)

Remove removes the specified element from the queue if it exists.

func (*Queue) RemoveAll added in v1.0.0

func (q *Queue) RemoveAll(values ...interface{}) (bool, error)

RemoveAll removes all of the elements of the specified collection from this queue.

func (*Queue) RemoveListener added in v1.0.0

func (q *Queue) RemoveListener(subscriptionID types.UUID) error

RemoveListener removes the specified listener.

func (*Queue) RetainAll added in v1.0.0

func (q *Queue) RetainAll(values ...interface{}) (bool, error)

RetainAll removes the items which are not contained in the specified collection.

func (*Queue) Size added in v1.0.0

func (q *Queue) Size() (int, error)

Size returns the number of elements in this collection.

func (*Queue) Take added in v1.0.0

func (q *Queue) Take() (interface{}, error)

Take retrieves and removes the head of this queue, if necessary, waits until an item becomes available.

type QueueItemNotified added in v1.0.0

type QueueItemNotified struct {
	Value     interface{}
	Member    cluster.Member
	QueueName string
	EventType ItemEventType
}

func (QueueItemNotified) EventName added in v1.0.0

func (q QueueItemNotified) EventName() string

type QueueItemNotifiedHandler added in v1.0.0

type QueueItemNotifiedHandler func(event *QueueItemNotified)

type ReplicatedMap added in v1.0.0

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

func (*ReplicatedMap) AddEntryListener added in v1.0.0

func (m *ReplicatedMap) AddEntryListener(handler EntryNotifiedHandler) (types.UUID, error)

AddEntryListener adds a continuous entry listener to this map.

func (*ReplicatedMap) AddEntryListenerToKey added in v1.0.0

func (m *ReplicatedMap) AddEntryListenerToKey(key interface{}, handler EntryNotifiedHandler) (types.UUID, error)

AddEntryListenerToKey adds a continuous entry listener to this map.

func (*ReplicatedMap) AddEntryListenerToKeyWithPredicate added in v1.0.0

func (m *ReplicatedMap) AddEntryListenerToKeyWithPredicate(key interface{}, predicate predicate.Predicate, handler EntryNotifiedHandler) (types.UUID, error)

AddEntryListenerToKeyWithPredicate adds a continuous entry listener to this map.

func (*ReplicatedMap) AddEntryListenerWithPredicate added in v1.0.0

func (m *ReplicatedMap) AddEntryListenerWithPredicate(predicate predicate.Predicate, handler EntryNotifiedHandler) (types.UUID, error)

AddEntryListenerWithPredicate adds a continuous entry listener to this map.

func (*ReplicatedMap) Clear added in v1.0.0

func (m *ReplicatedMap) Clear() error

Clear deletes all entries one by one and fires related events

func (*ReplicatedMap) ContainsKey added in v1.0.0

func (m *ReplicatedMap) ContainsKey(key interface{}) (bool, error)

ContainsKey returns true if the map contains an entry with the given key

func (*ReplicatedMap) ContainsValue added in v1.0.0

func (m *ReplicatedMap) ContainsValue(value interface{}) (bool, error)

ContainsValue returns true if the map contains an entry with the given value

func (ReplicatedMap) Destroy added in v1.0.0

func (p ReplicatedMap) Destroy() error

Destroys this object cluster-wide. Clears and releases all resources for this object.

func (*ReplicatedMap) Get added in v1.0.0

func (m *ReplicatedMap) Get(key interface{}) (interface{}, error)

Get returns the value for the specified key, or nil if this map does not contain this key. Warning:

This method returns a clone of original value, modifying the returned value does not change the
actual value in the map. One should put modified value back to make changes visible to all nodes.

func (*ReplicatedMap) GetEntrySet added in v1.0.0

func (m *ReplicatedMap) GetEntrySet() ([]types.Entry, error)

GetEntrySet returns a clone of the mappings contained in this map.

func (*ReplicatedMap) GetKeySet added in v1.0.0

func (m *ReplicatedMap) GetKeySet() ([]interface{}, error)

GetKeySet returns keys contained in this map

func (*ReplicatedMap) GetValues added in v1.0.0

func (m *ReplicatedMap) GetValues() ([]interface{}, error)

GetValues returns a list clone of the values contained in this map

func (*ReplicatedMap) IsEmpty added in v1.0.0

func (m *ReplicatedMap) IsEmpty() (bool, error)

IsEmpty returns true if this map contains no key-value mappings.

func (*ReplicatedMap) Put added in v1.0.0

func (m *ReplicatedMap) Put(key interface{}, value interface{}) (interface{}, error)

Put sets the value for the given key and returns the old value.

func (*ReplicatedMap) PutAll added in v1.0.0

func (m *ReplicatedMap) PutAll(keyValuePairs []types.Entry) error

PutAll copies all of the mappings from the specified map to this map. No atomicity guarantees are given. In the case of a failure, some of the key-value tuples may get written, while others are not.

func (*ReplicatedMap) Remove added in v1.0.0

func (m *ReplicatedMap) Remove(key interface{}) (interface{}, error)

Remove deletes the value for the given key and returns it.

func (*ReplicatedMap) RemoveEntryListener added in v1.0.0

func (m *ReplicatedMap) RemoveEntryListener(subscriptionID types.UUID) error

RemoveEntryListener removes the specified entry listener.

func (*ReplicatedMap) Size added in v1.0.0

func (m *ReplicatedMap) Size() (int, error)

Size returns the number of entries in this map.

type Set added in v1.0.0

type Set struct {
	// contains filtered or unexported fields
}
Set is a concurrent, distributed set implementation.

Hazelcast Set is a distributed set which does not allow duplicate elements. For details, see the Set section in the Hazelcast Reference Manual: https://docs.hazelcast.org/docs/latest/manual/html-single/index.html#set

Example
// Create the Hazelcast client.
client, err := hazelcast.StartNewClient()
if err != nil {
	log.Fatal(err)
}
// Retrieve the set named my-set
set, err := client.GetSet("my-set")
if err != nil {
	log.Fatal(err)
}
_, err = set.AddAll("item1", "item2", "item3", "item2", "item1")
if err != nil {
	log.Fatal(err)
}
// Get the items. Note that there are no duplicates.
items, err := set.GetAll()
if err != nil {
	log.Fatal(err)
}
for _, item := range items {
	fmt.Println("Item:", item)
}
Output:

func (*Set) Add added in v1.0.0

func (s *Set) Add(item interface{}) (bool, error)

Add adds the given item to the set. Returns true if the item was not already in the set.

func (*Set) AddAll added in v1.0.0

func (s *Set) AddAll(values ...interface{}) (bool, error)

AddAll adds the elements in the specified collection to this set. Returns true if the set is changed after the call.

func (*Set) AddListener

func (s *Set) AddListener(handler SetItemNotifiedHandler) (types.UUID, error)

AddListener adds an item listener for this set. Listener will be notified for all set add/remove events.

func (*Set) AddListenerIncludeValue

func (s *Set) AddListenerIncludeValue(handler SetItemNotifiedHandler) (types.UUID, error)

AddListenerIncludeValue adds an item listener for this set. Listener will be notified for all set add/remove events. Received events include the updated item.

func (*Set) Clear added in v1.0.0

func (s *Set) Clear() error

Clear clears this set. Set will be empty after this call.

func (*Set) Contains added in v1.0.0

func (s *Set) Contains(value interface{}) (bool, error)

Contains returns true if the set includes the given value.

func (*Set) ContainsAll added in v1.0.0

func (s *Set) ContainsAll(values ...interface{}) (bool, error)

ContainsAll returns true if the set includes all given values.

func (Set) Destroy added in v1.0.0

func (p Set) Destroy() error

Destroys this object cluster-wide. Clears and releases all resources for this object.

func (*Set) GetAll added in v1.0.0

func (s *Set) GetAll() ([]interface{}, error)

GetAll returns the entries for the given keys.

func (*Set) IsEmpty added in v1.0.0

func (s *Set) IsEmpty() (bool, error)

IsEmpty returns true if the set is empty.

func (*Set) Remove added in v1.0.0

func (s *Set) Remove(value interface{}) (bool, error)

Remove removes the specified element from the set if it exists.

func (*Set) RemoveAll added in v1.0.0

func (s *Set) RemoveAll(values ...interface{}) (bool, error)

RemoveAll removes all of the elements of the specified collection from this set. Returns true if the set was changed.

func (*Set) RemoveListener added in v1.0.0

func (s *Set) RemoveListener(subscriptionID types.UUID) error

RemoveListener removes the specified listener.

func (*Set) RetainAll added in v1.0.0

func (s *Set) RetainAll(values ...interface{}) (bool, error)

RetainAll removes the items which are not contained in the specified collection. Returns true if the set was changed.

func (*Set) Size added in v1.0.0

func (s *Set) Size() (int, error)

Size returns the number of elements in this set.

type SetItemNotified added in v1.0.0

type SetItemNotified struct {
	Value     interface{}
	Member    cluster.Member
	SetName   string
	EventType ItemEventType
}

func (SetItemNotified) EventName added in v1.0.0

func (q SetItemNotified) EventName() string

type SetItemNotifiedHandler added in v1.0.0

type SetItemNotifiedHandler func(event *SetItemNotified)

type Topic added in v1.0.0

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

Topic is a distribution mechanism for publishing messages that are delivered to multiple subscribers, which is also known as a publish/subscribe (pub/sub) messaging model.

Publish and subscriptions are cluster-wide. When a member subscribes for a topic, it is actually registering for messages published by any member in the cluster, including the new members joined after you added the listener.

Messages are ordered, meaning that listeners(subscribers) will process the messages in the order they are actually published.

func (*Topic) AddListener

func (t *Topic) AddListener(handler TopicMessageHandler) (types.UUID, error)

AddListener adds a subscriber to this topic.

func (Topic) Destroy added in v1.0.0

func (p Topic) Destroy() error

Destroys this object cluster-wide. Clears and releases all resources for this object.

func (*Topic) Publish added in v1.0.0

func (t *Topic) Publish(message interface{}) error

Publish publishes the given message to all subscribers of this topic.

func (*Topic) PublishAll added in v1.0.0

func (t *Topic) PublishAll(messages ...interface{}) error

PublishAll published all given messages to all subscribers of this topic.

func (*Topic) RemoveListener added in v1.0.0

func (t *Topic) RemoveListener(subscriptionID types.UUID) error

RemoveListener removes the given subscription from this topic.

type TopicMessageHandler added in v1.0.0

type TopicMessageHandler func(event *MessagePublished)

Directories

Path Synopsis
examples
Package serialization serializes user objects to Data and back to Object.
Package serialization serializes user objects to Data and back to Object.
Package types contains various helper types.
Package types contains various helper types.
cb
it
proto/codec
* Copyright (c) 2008-2021, Hazelcast, Inc.
* Copyright (c) 2008-2021, Hazelcast, Inc.

Jump to

Keyboard shortcuts

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