Documentation
¶
Overview ¶
Package hazelcast provides the Hazelcast Go client.
Hazelcast Cloud Discovery ¶
Hazelcast Go client can discover and connect to Hazelcast clusters running on Hazelcast Cloud https://cloud.hazelcast.com. In order to activate it, set the cluster name, enable Hazelcast Cloud discovery and add Hazelcast Cloud Token to the configuration. Here is an example:
config := hazelcast.NewConfig() config.ClusterConfig.Name = "MY-CLUSTER-NAME" cc := &config.ClusterConfig.HazelcastCloudConfig cc.Enabled = true cc.Token = "MY-CLUSTER-TOKEN" client, err := hazelcast.StartNewClientWithConfig(config) if err != nil { log.Fatal(err) }
Also check the code sample in https://github.com/hazelcast/hazelcast-go-client/tree/master/examples/discovery/cloud.
If you have enabled encryption for your cluster, you should also enable TLS/SSL configuration for the client.
External Client Public Address Discovery ¶
When you set up a Hazelcast cluster in the Cloud (AWS, Azure, GCP, Kubernetes) and would like to use it from outside the Cloud network, the client needs to communicate with all cluster members via their public IP addresses. Whenever Hazelcast cluster members are able to resolve their own public external IP addresses, they pass this information to the client. As a result, the client can use public addresses for communication, if it cannot access members via private IPs.
Hazelcast Go client has a built-in mechanism to use public IP addresses instead of private ones. You can enable this feature by setting config.DiscoveryConfig.UsePublicIP to true and specifying the adddress of at least one member:
config := hazelcast.NewConfig() cc := &config.ClusterConfig cc.SetAddress("30.40.50.60:5701") cc.DiscoveryConfig.UsePublicIP = true
For more details on member-side configuration, refer to the Discovery SPI section in the Hazelcast IMDG Reference Manual.
Listening for Distributed Object Events ¶
You can listen to creation and destroy events for distributed objects by attaching a listener to the client. A distributed object is created when first referenced unless it already exists. Here is an example:
// Error handling is omitted for brevity. handler := func(e hazelcast.DistributedObjectNotified) { isMapEvent := e.ServiceName == hazelcast.ServiceNameMap isCreationEvent := e.EventType == hazelcast.DistributedObjectCreated log.Println(e.EventType, e.ServiceName, e.ObjectName, "creation?", isCreationEvent, "isMap?", isMapEvent) } subscriptionID, _ := client.AddDistributedObjectListener(handler) myMap, _ := client.GetMap("my-map") // handler is called with: ServiceName=ServiceNameMap; ObjectName="my-map"; EventType=DistributedObjectCreated myMap.Destroy() // handler is called with: ServiceName=ServiceNameMap; ObjectName="my-map"; EventType=DistributedObjectDestroyed
If you don't want to receive any distributed object events, use client.RemoveDistributedObjectListener:
client.RemoveDistributedObjectListener(subscriptionID)
Collecting Statistics ¶
Hazelcast Management Center can monitor your clients if client-side statistics are enabled.
You can enable statistics by setting config.StatsConfig.Enabled to true. Optionally, the period of statistics collection can be set using config.StatsConfig.Period setting.
config := hazelcast.NewConfig() config.StatsConfig.Enabled = true config.StatsConfig.Period = 1 * time.Second client, err := hazelcast.StartNewClientWithConfig(config)
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) AddDistributedObjectListener(ctx context.Context, handler DistributedObjectNotifiedHandler) (types.UUID, error)
- func (c *Client) AddLifecycleListener(handler LifecycleStateChangeHandler) (types.UUID, error)
- func (c *Client) AddMembershipListener(handler cluster.MembershipStateChangeHandler) (types.UUID, error)
- func (c *Client) GetList(ctx context.Context, name string) (*List, error)
- func (c *Client) GetMap(ctx context.Context, name string) (*Map, error)
- func (c *Client) GetPNCounter(ctx context.Context, name string) (*PNCounter, error)
- func (c *Client) GetQueue(ctx context.Context, name string) (*Queue, error)
- func (c *Client) GetReplicatedMap(ctx context.Context, name string) (*ReplicatedMap, error)
- func (c *Client) GetSet(ctx context.Context, name string) (*Set, error)
- func (c *Client) GetTopic(ctx context.Context, name string) (*Topic, error)
- func (c *Client) Name() string
- func (c *Client) RemoveDistributedObjectListener(ctx context.Context, subscriptionID types.UUID) error
- func (c *Client) RemoveLifecycleListener(subscriptionID types.UUID) error
- func (c *Client) RemoveMembershipListener(subscriptionID types.UUID) error
- func (c *Client) Running() bool
- func (c *Client) Shutdown() error
- type Config
- type DistributedObjectEventType
- type DistributedObjectNotified
- type DistributedObjectNotifiedHandler
- type EntryNotified
- type EntryNotifiedHandler
- type IndexValidationError
- type ItemEventType
- type LifecycleState
- type LifecycleStateChangeHandler
- type LifecycleStateChanged
- type List
- func (l *List) Add(ctx context.Context, element interface{}) (bool, error)
- func (l *List) AddAll(ctx context.Context, elements ...interface{}) (bool, error)
- func (l *List) AddAllAt(ctx context.Context, index int, elements ...interface{}) (bool, error)
- func (l *List) AddAt(ctx context.Context, index int, element interface{}) error
- func (l *List) AddListener(ctx context.Context, handler ListItemNotifiedHandler) (types.UUID, error)
- func (l *List) AddListenerIncludeValue(ctx context.Context, handler ListItemNotifiedHandler) (types.UUID, error)
- func (l *List) Clear(ctx context.Context) error
- func (l *List) Contains(ctx context.Context, element interface{}) (bool, error)
- func (l *List) ContainsAll(ctx context.Context, elements ...interface{}) (bool, error)
- func (p List) Destroy(ctx context.Context) error
- func (l *List) Get(ctx context.Context, index int) (interface{}, error)
- func (l *List) GetAll(ctx context.Context) ([]interface{}, error)
- func (l *List) IndexOf(ctx context.Context, element interface{}) (int, error)
- func (l *List) IsEmpty(ctx context.Context) (bool, error)
- func (l *List) LastIndexOf(ctx context.Context, element interface{}) (int, error)
- func (l *List) Remove(ctx context.Context, element interface{}) (bool, error)
- func (l *List) RemoveAll(ctx context.Context, elements ...interface{}) (bool, error)
- func (l *List) RemoveAt(ctx context.Context, index int) (interface{}, error)
- func (l *List) RemoveListener(ctx context.Context, subscriptionID types.UUID) error
- func (l *List) RetainAll(ctx context.Context, elements ...interface{}) (bool, error)
- func (l *List) Set(ctx context.Context, index int, element interface{}) (interface{}, error)
- func (l *List) Size(ctx context.Context) (int, error)
- func (l *List) SubList(ctx context.Context, start int, end int) ([]interface{}, error)
- type ListItemNotified
- type ListItemNotifiedHandler
- type Map
- func (m *Map) AddEntryListener(ctx context.Context, config MapEntryListenerConfig, ...) (types.UUID, error)
- func (m *Map) AddIndexWithConfig(ctx context.Context, indexConfig types.IndexConfig) error
- func (m *Map) AddInterceptor(ctx context.Context, interceptor interface{}) (string, error)
- func (m *Map) Clear(ctx context.Context) error
- func (m *Map) ContainsKey(ctx context.Context, key interface{}) (bool, error)
- func (m *Map) ContainsValue(ctx context.Context, value interface{}) (bool, error)
- func (m *Map) Delete(ctx context.Context, key interface{}) error
- func (p Map) Destroy(ctx context.Context) error
- func (m *Map) Evict(ctx context.Context, key interface{}) (bool, error)
- func (m *Map) EvictAll(ctx context.Context) error
- func (m *Map) ExecuteOnEntries(ctx context.Context, entryProcessor interface{}) ([]types.Entry, error)
- func (m *Map) Flush(ctx context.Context) error
- func (m *Map) ForceUnlock(ctx context.Context, key interface{}) error
- func (m *Map) Get(ctx context.Context, key interface{}) (interface{}, error)
- func (m *Map) GetAll(ctx context.Context, keys ...interface{}) ([]types.Entry, error)
- func (m *Map) GetEntrySet(ctx context.Context) ([]types.Entry, error)
- func (m *Map) GetEntrySetWithPredicate(ctx context.Context, predicate predicate.Predicate) ([]types.Entry, error)
- func (m *Map) GetEntryView(ctx context.Context, key interface{}) (*types.SimpleEntryView, error)
- func (m *Map) GetKeySet(ctx context.Context) ([]interface{}, error)
- func (m *Map) GetKeySetWithPredicate(ctx context.Context, predicate predicate.Predicate) ([]interface{}, error)
- func (m *Map) GetValues(ctx context.Context) ([]interface{}, error)
- func (m *Map) GetValuesWithPredicate(ctx context.Context, predicate predicate.Predicate) ([]interface{}, error)
- func (m *Map) IsEmpty(ctx context.Context) (bool, error)
- func (m *Map) IsLocked(ctx context.Context, key interface{}) (bool, error)
- func (m *Map) LoadAllReplacing(ctx context.Context, keys ...interface{}) error
- func (m *Map) LoadAllWithoutReplacing(ctx context.Context, keys ...interface{}) error
- func (m *Map) Lock(ctx context.Context, key interface{}) error
- func (m *Map) LockWithLease(ctx context.Context, key interface{}, leaseTime time.Duration) error
- func (m *Map) NewLockContext(ctx context.Context) context.Context
- func (m *Map) Put(ctx context.Context, key interface{}, value interface{}) (interface{}, error)
- func (m *Map) PutAll(ctx context.Context, entries ...types.Entry) error
- func (m *Map) PutIfAbsent(ctx context.Context, key interface{}, value interface{}) (interface{}, error)
- func (m *Map) PutIfAbsentWithTTL(ctx context.Context, key interface{}, value interface{}, ttl time.Duration) (interface{}, error)
- func (m *Map) PutIfAbsentWithTTLAndMaxIdle(ctx context.Context, key interface{}, value interface{}, ttl time.Duration, ...) (interface{}, error)
- func (m *Map) PutTransient(ctx context.Context, key interface{}, value interface{}) error
- func (m *Map) PutTransientWithMaxIdle(ctx context.Context, key interface{}, value interface{}, maxIdle time.Duration) error
- func (m *Map) PutTransientWithTTL(ctx context.Context, key interface{}, value interface{}, ttl time.Duration) error
- func (m *Map) PutTransientWithTTLAndMaxIdle(ctx context.Context, key interface{}, value interface{}, ttl time.Duration, ...) error
- func (m *Map) PutWithMaxIdle(ctx context.Context, key interface{}, value interface{}, maxIdle time.Duration) (interface{}, error)
- func (m *Map) PutWithTTL(ctx context.Context, key interface{}, value interface{}, ttl time.Duration) (interface{}, error)
- func (m *Map) PutWithTTLAndMaxIdle(ctx context.Context, key interface{}, value interface{}, ttl time.Duration, ...) (interface{}, error)
- func (m *Map) Remove(ctx context.Context, key interface{}) (interface{}, error)
- func (m *Map) RemoveAll(ctx context.Context, predicate predicate.Predicate) error
- func (m *Map) RemoveEntryListener(ctx context.Context, subscriptionID types.UUID) error
- func (m *Map) RemoveIfSame(ctx context.Context, key interface{}, value interface{}) (bool, error)
- func (m *Map) RemoveInterceptor(ctx context.Context, registrationID string) (bool, error)
- func (m *Map) Replace(ctx context.Context, key interface{}, value interface{}) (interface{}, error)
- func (m *Map) ReplaceIfSame(ctx context.Context, key interface{}, oldValue interface{}, ...) (bool, error)
- func (m *Map) Set(ctx context.Context, key interface{}, value interface{}) error
- func (m *Map) SetTTL(ctx context.Context, key interface{}, ttl time.Duration) error
- func (m *Map) SetWithTTL(ctx context.Context, key interface{}, value interface{}, ttl time.Duration) error
- func (m *Map) SetWithTTLAndMaxIdle(ctx context.Context, key interface{}, value interface{}, ttl time.Duration, ...) error
- func (m *Map) Size(ctx context.Context) (int, error)
- func (m *Map) TryLock(ctx context.Context, key interface{}) (bool, error)
- func (m *Map) TryLockWithLease(ctx context.Context, key interface{}, lease time.Duration) (bool, error)
- func (m *Map) TryLockWithLeaseTimeout(ctx context.Context, key interface{}, lease time.Duration, ...) (bool, error)
- func (m *Map) TryLockWithTimeout(ctx context.Context, key interface{}, timeout time.Duration) (bool, error)
- func (m *Map) TryPut(ctx context.Context, key interface{}, value interface{}) (bool, error)
- func (m *Map) TryPutWithTimeout(ctx context.Context, key interface{}, value interface{}, timeout time.Duration) (bool, error)
- func (m *Map) TryRemove(ctx context.Context, key interface{}) (interface{}, error)
- func (m *Map) TryRemoveWithTimeout(ctx context.Context, key interface{}, timeout time.Duration) (interface{}, error)
- func (m *Map) Unlock(ctx context.Context, key interface{}) error
- type MapEntryListenerConfig
- func (c *MapEntryListenerConfig) NotifyEntryAdded(enable bool)
- func (c *MapEntryListenerConfig) NotifyEntryAllCleared(enable bool)
- func (c *MapEntryListenerConfig) NotifyEntryAllEvicted(enable bool)
- func (c *MapEntryListenerConfig) NotifyEntryEvicted(enable bool)
- func (c *MapEntryListenerConfig) NotifyEntryExpired(enable bool)
- func (c *MapEntryListenerConfig) NotifyEntryInvalidated(enable bool)
- func (c *MapEntryListenerConfig) NotifyEntryLoaded(enable bool)
- func (c *MapEntryListenerConfig) NotifyEntryMerged(enable bool)
- func (c *MapEntryListenerConfig) NotifyEntryRemoved(enable bool)
- func (c *MapEntryListenerConfig) NotifyEntryUpdated(enable bool)
- type MessagePublished
- type PNCounter
- func (pn *PNCounter) AddAndGet(ctx context.Context, delta int64) (int64, error)
- func (pn *PNCounter) DecrementAndGet(ctx context.Context) (int64, error)
- func (p PNCounter) Destroy(ctx context.Context) error
- func (pn *PNCounter) Get(ctx context.Context) (int64, error)
- func (pn *PNCounter) GetAndAdd(ctx context.Context, delta int64) (int64, error)
- func (pn *PNCounter) GetAndDecrement(ctx context.Context) (int64, error)
- func (pn *PNCounter) GetAndIncrement(ctx context.Context) (int64, error)
- func (pn *PNCounter) GetAndSubtract(ctx context.Context, delta int64) (int64, error)
- func (pn *PNCounter) IncrementAndGet(ctx context.Context) (int64, error)
- func (pn *PNCounter) Reset()
- func (pn *PNCounter) SubtractAndGet(ctx context.Context, delta int64) (int64, error)
- type Queue
- func (q *Queue) Add(ctx context.Context, value interface{}) (bool, error)
- func (q *Queue) AddAll(ctx context.Context, values ...interface{}) (bool, error)
- func (q *Queue) AddListener(ctx context.Context, handler QueueItemNotifiedHandler) (types.UUID, error)
- func (q *Queue) AddListenerIncludeValue(ctx context.Context, handler QueueItemNotifiedHandler) (types.UUID, error)
- func (q *Queue) AddWithTimeout(ctx context.Context, value interface{}, timeout time.Duration) (bool, error)
- func (q *Queue) Clear(ctx context.Context) error
- func (q *Queue) Contains(ctx context.Context, value interface{}) (bool, error)
- func (q *Queue) ContainsAll(ctx context.Context, values ...interface{}) (bool, error)
- func (p Queue) Destroy(ctx context.Context) error
- func (q *Queue) Drain(ctx context.Context) ([]interface{}, error)
- func (q *Queue) DrainWithMaxSize(ctx context.Context, maxSize int) ([]interface{}, error)
- func (q *Queue) GetAll(ctx context.Context) ([]interface{}, error)
- func (q *Queue) IsEmpty(ctx context.Context) (bool, error)
- func (q *Queue) Peek(ctx context.Context) (interface{}, error)
- func (q *Queue) Poll(ctx context.Context) (interface{}, error)
- func (q *Queue) PollWithTimeout(ctx context.Context, timeout time.Duration) (interface{}, error)
- func (q *Queue) Put(ctx context.Context, value interface{}) error
- func (q *Queue) RemainingCapacity(ctx context.Context) (int, error)
- func (q *Queue) Remove(ctx context.Context, value interface{}) (bool, error)
- func (q *Queue) RemoveAll(ctx context.Context, values ...interface{}) (bool, error)
- func (q *Queue) RemoveListener(ctx context.Context, subscriptionID types.UUID) error
- func (q *Queue) RetainAll(ctx context.Context, values ...interface{}) (bool, error)
- func (q *Queue) Size(ctx context.Context) (int, error)
- func (q *Queue) Take(ctx context.Context) (interface{}, error)
- type QueueItemNotified
- type QueueItemNotifiedHandler
- type ReplicatedMap
- func (m *ReplicatedMap) AddEntryListener(ctx context.Context, handler EntryNotifiedHandler) (types.UUID, error)
- func (m *ReplicatedMap) AddEntryListenerToKey(ctx context.Context, key interface{}, handler EntryNotifiedHandler) (types.UUID, error)
- func (m *ReplicatedMap) AddEntryListenerToKeyWithPredicate(ctx context.Context, key interface{}, predicate predicate.Predicate, ...) (types.UUID, error)
- func (m *ReplicatedMap) AddEntryListenerWithPredicate(ctx context.Context, predicate predicate.Predicate, ...) (types.UUID, error)
- func (m *ReplicatedMap) Clear(ctx context.Context) error
- func (m *ReplicatedMap) ContainsKey(ctx context.Context, key interface{}) (bool, error)
- func (m *ReplicatedMap) ContainsValue(ctx context.Context, value interface{}) (bool, error)
- func (p ReplicatedMap) Destroy(ctx context.Context) error
- func (m *ReplicatedMap) Get(ctx context.Context, key interface{}) (interface{}, error)
- func (m *ReplicatedMap) GetEntrySet(ctx context.Context) ([]types.Entry, error)
- func (m *ReplicatedMap) GetKeySet(ctx context.Context) ([]interface{}, error)
- func (m *ReplicatedMap) GetValues(ctx context.Context) ([]interface{}, error)
- func (m *ReplicatedMap) IsEmpty(ctx context.Context) (bool, error)
- func (m *ReplicatedMap) Put(ctx context.Context, key interface{}, value interface{}) (interface{}, error)
- func (m *ReplicatedMap) PutAll(ctx context.Context, keyValuePairs []types.Entry) error
- func (m *ReplicatedMap) Remove(ctx context.Context, key interface{}) (interface{}, error)
- func (m *ReplicatedMap) RemoveEntryListener(ctx context.Context, subscriptionID types.UUID) error
- func (m *ReplicatedMap) Size(ctx context.Context) (int, error)
- type Set
- func (s *Set) Add(ctx context.Context, item interface{}) (bool, error)
- func (s *Set) AddAll(ctx context.Context, values ...interface{}) (bool, error)
- func (s *Set) AddListener(ctx context.Context, handler SetItemNotifiedHandler) (types.UUID, error)
- func (s *Set) AddListenerIncludeValue(ctx context.Context, handler SetItemNotifiedHandler) (types.UUID, error)
- func (s *Set) Clear(ctx context.Context) error
- func (s *Set) Contains(ctx context.Context, value interface{}) (bool, error)
- func (s *Set) ContainsAll(ctx context.Context, values ...interface{}) (bool, error)
- func (p Set) Destroy(ctx context.Context) error
- func (s *Set) GetAll(ctx context.Context) ([]interface{}, error)
- func (s *Set) IsEmpty(ctx context.Context) (bool, error)
- func (s *Set) Remove(ctx context.Context, value interface{}) (bool, error)
- func (s *Set) RemoveAll(ctx context.Context, values ...interface{}) (bool, error)
- func (s *Set) RemoveListener(ctx context.Context, subscriptionID types.UUID) error
- func (s *Set) RetainAll(ctx context.Context, values ...interface{}) (bool, error)
- func (s *Set) Size(ctx context.Context) (int, error)
- type SetItemNotified
- type SetItemNotifiedHandler
- type StatsConfig
- type Topic
- func (t *Topic) AddListener(ctx context.Context, handler TopicMessageHandler) (types.UUID, error)
- func (p Topic) Destroy(ctx context.Context) error
- func (t *Topic) Publish(ctx context.Context, message interface{}) error
- func (t *Topic) PublishAll(ctx context.Context, messages ...interface{}) error
- func (t *Topic) RemoveListener(ctx context.Context, subscriptionID types.UUID) error
- type TopicMessageHandler
Constants ¶
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) )
const ( ServiceNameMap = "hz:impl:mapService" ServiceNameReplicatedMap = "hz:impl:replicatedMapService" ServiceNameQueue = "hz:impl:queueService" ServiceNameTopic = "hz:impl:topicService" ServiceNameList = "hz:impl:listService" ServiceNameSet = "hz:impl:setService" ServiceNamePNCounter = "hz:impl:PNCounterService" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func StartNewClient ¶ added in v1.0.0
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
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) AddDistributedObjectListener ¶ added in v1.0.0
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) GetPNCounter ¶
GetPNCounter returns a PNCounter instance.
func (*Client) GetReplicatedMap ¶
func (*Client) Name ¶
Name returns client's name Use ConfigBuilder.SetName to set the client name. If not set manually, an automatic name is used.
func (*Client) RemoveDistributedObjectListener ¶ added in v1.0.0
func (*Client) RemoveLifecycleListener ¶ added in v1.0.0
RemoveLifecycleListener removes the lifecycle state change handler with the given subscription ID
func (*Client) RemoveMembershipListener ¶ added in v1.0.0
RemoveMembershipListener removes the member state change handler with the given subscription ID.
type Config ¶ added in v1.0.0
type Config struct { Labels []string ClientName string LoggerConfig logger.Config SerializationConfig serialization.Config ClusterConfig cluster.Config StatsConfig StatsConfig // contains filtered or unexported fields }
Config contains configuration for a client. Prefer to create the configuration using the NewConfig function.
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.
type DistributedObjectEventType ¶ added in v1.0.0
type DistributedObjectEventType string
const ( DistributedObjectCreated DistributedObjectEventType = "CREATED" DistributedObjectDestroyed DistributedObjectEventType = "DESTROYED" )
type DistributedObjectNotified ¶ added in v1.0.0
type DistributedObjectNotified struct { ServiceName string ObjectName string EventType DistributedObjectEventType }
func (DistributedObjectNotified) EventName ¶ added in v1.0.0
func (d DistributedObjectNotified) EventName() string
type DistributedObjectNotifiedHandler ¶ added in v1.0.0
type DistributedObjectNotifiedHandler func(event DistributedObjectNotified)
type EntryNotified ¶ added in v1.0.0
type EntryNotified struct { MergingValue interface{} Key interface{} Value interface{} OldValue interface{} MapName string Member cluster.MemberInfo 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 )
func (LifecycleState) String ¶ added in v1.0.0
func (s LifecycleState) String() string
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
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
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
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
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(ctx context.Context, 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(ctx context.Context, handler ListItemNotifiedHandler) (types.UUID, error)
AddListenerIncludeValue 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) Contains ¶ added in v1.0.0
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
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
Destroy removes this object cluster-wide. Clears and releases all resources for this object.
func (*List) GetAll ¶ added in v1.0.0
GetAll returns a slice that contains all elements of this list in proper sequence.
func (*List) IndexOf ¶ added in v1.0.0
IndexOf returns the index of the first occurrence of the given element in this list.
func (*List) LastIndexOf ¶ added in v1.0.0
LastIndexOf returns the index of the last occurrence of the given element in this list.
func (*List) Remove ¶ added in v1.0.0
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
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
RemoveAt removes the element at the given index. Returns the removed element.
func (*List) RemoveListener ¶ added in v1.0.0
RemoveListener removes the item listener with the given subscription ID.
func (*List) RetainAll ¶ added in v1.0.0
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
Set replaces the element at the specified index in this list with the specified element. Returns the previous element from the list.
type ListItemNotified ¶ added in v1.0.0
type ListItemNotified struct { Value interface{} ListName string Member cluster.MemberInfo 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(ctx context.Context, config MapEntryListenerConfig, handler EntryNotifiedHandler) (types.UUID, error)
AddEntryListener adds a continuous entry listener to this map.
func (*Map) AddIndexWithConfig ¶
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
AddInterceptor adds an interceptor for this map.
func (*Map) ContainsKey ¶ added in v1.0.0
ContainsKey returns true if the map contains an entry with the given key
func (*Map) ContainsValue ¶ added in v1.0.0
ContainsValue returns true if the map contains an entry with the given value
func (*Map) Delete ¶ added in v1.0.0
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
Destroy removes this object cluster-wide. Clears and releases all resources for this object.
func (*Map) Evict ¶ added in v1.0.0
Evict evicts the mapping for a key from this map. Returns true if the key is evicted.
func (*Map) ExecuteOnEntries ¶ added in v1.0.0
func (m *Map) ExecuteOnEntries(ctx context.Context, entryProcessor interface{}) ([]types.Entry, error)
ExecuteOnEntries applies the user defined EntryProcessor to all the entries in the map.
func (*Map) ForceUnlock ¶ added in v1.0.0
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
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) GetEntrySet ¶ added in v1.0.0
GetEntrySet returns a clone of the mappings contained in this map.
func (*Map) GetEntrySetWithPredicate ¶ added in v1.0.0
func (m *Map) GetEntrySetWithPredicate(ctx context.Context, 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
GetEntryView returns the SimpleEntryView for the specified key. If there is no entry view for the key, nil is returned.
func (*Map) GetKeySetWithPredicate ¶ added in v1.0.0
func (m *Map) GetKeySetWithPredicate(ctx context.Context, predicate predicate.Predicate) ([]interface{}, error)
GetKeySetWithPredicate returns keys contained in this map
func (*Map) GetValues ¶ added in v1.0.0
GetValues returns a list clone of the values contained in this map
func (*Map) GetValuesWithPredicate ¶ added in v1.0.0
func (m *Map) GetValuesWithPredicate(ctx context.Context, 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
IsEmpty returns true if this map contains no key-value mappings.
func (*Map) LoadAllReplacing ¶ added in v1.0.0
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
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
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
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) NewLockContext ¶ added in v1.0.0
NewLockContext augments the passed parent context with a unique lock ID. If passed context is nil, context.Background is used as the parent context.
func (*Map) PutAll ¶ added in v1.0.0
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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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
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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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) RemoveEntryListener ¶ added in v1.0.0
RemoveEntryListener removes the specified entry listener.
func (*Map) RemoveIfSame ¶ added in v1.0.0
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
RemoveInterceptor removes the interceptor.
func (*Map) Replace ¶ added in v1.0.0
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(ctx context.Context, 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) SetTTL ¶ added in v1.0.0
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(ctx context.Context, 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(ctx context.Context, 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) TryLock ¶ added in v1.0.0
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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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
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(ctx context.Context, key interface{}, value interface{}, timeout time.Duration) (bool, error)
TryPutWithTimeout 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
TryRemove tries to remove the given key from this map and returns immediately.
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{} TopicName string Member cluster.MemberInfo }
func (*MessagePublished) EventName ¶ added in v1.0.0
func (m *MessagePublished) EventName() string
type PNCounter ¶ added in v1.0.0
type PNCounter struct {
// contains filtered or unexported fields
}
PNCounter is a PN (Positive-Negative) CRDT counter.
The counter supports adding and subtracting values as well as retrieving the current counter value. Each replica of this counter can perform operations locally without coordination with the other replicas, thus increasing availability. The counter guarantees that whenever two nodes have received the same set of updates, possibly in a different order, their state is identical, and any conflicting updates are merged automatically. If no new updates are made to the shared state, all nodes that can communicate will eventually have the same data.
When invoking updates from the client, the invocation is remote. This may lead to indeterminate state - the update may be applied but the response has not been received. In this case, the caller will be notified with a TargetDisconnectedError.
The read and write methods provide monotonic read and RYW (read-your-write) guarantees. These guarantees are session guarantees which means that if no replica with the previously observed state is reachable, the session guarantees are lost and the method invocation will throw an hzerrors.HazelcastConsistencyLostError. This does not mean that an update is lost. All of the updates are part of some replica and will be eventually reflected in the state of all other replicas. This exception just means that you cannot observe your own writes because all replicas that contain your updates are currently unreachable. After you have received an hzerrors.HazelcastConsistencyLostError, you can either wait for a sufficiently up-to-date replica to become reachable in which case the session can be continued or you can reset the session by calling the reset() method. If you have called the reset() method, a new session is started with the next invocation to a CRDT replica.
Notes: The CRDT state is kept entirely on non-lite (data) members. If there aren't any and the methods here are invoked on a lite member, they will fail with an NoDataMemberInClusterError.
func (*PNCounter) AddAndGet ¶ added in v1.0.0
AddAndGet adds the given value to the current value and returns the updated value.
func (*PNCounter) DecrementAndGet ¶ added in v1.0.0
DecrementAndGet decrements the counter value by one and returns the updated value.
func (PNCounter) Destroy ¶ added in v1.0.0
Destroy removes this object cluster-wide. Clears and releases all resources for this object.
func (*PNCounter) GetAndAdd ¶ added in v1.0.0
GetAndAdd adds the given value to the current value and returns the previous value.
func (*PNCounter) GetAndDecrement ¶ added in v1.0.0
GetAndDecrement decrements the counter value by one and returns the previous value.
func (*PNCounter) GetAndIncrement ¶ added in v1.0.0
GetAndIncrement increments the counter value by one and returns the previous value.
func (*PNCounter) GetAndSubtract ¶ added in v1.0.0
GetAndSubtract subtracts the given value from the current value and returns the previous value.
func (*PNCounter) IncrementAndGet ¶ added in v1.0.0
IncrementAndGet increments the counter value by one and returns the updated value.
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
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
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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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) Contains ¶ added in v1.0.0
Contains returns true if the queue includes the given value.
func (*Queue) ContainsAll ¶ added in v1.0.0
ContainsAll returns true if the queue includes all given values.
func (Queue) Destroy ¶ added in v1.0.0
Destroy removes this object cluster-wide. Clears and releases all resources for this object.
func (*Queue) DrainWithMaxSize ¶ added in v1.0.0
DrainWithMaxSize returns maximum maxSize items in tne queue and removes returned items from the queue.
func (*Queue) Peek ¶ added in v1.0.0
Peek retrieves the head of queue without removing it from the queue.
func (*Queue) PollWithTimeout ¶ added in v1.0.0
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
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
RemainingCapacity returns the remaining capacity of this queue.
func (*Queue) Remove ¶ added in v1.0.0
Remove removes the specified element from the queue if it exists.
func (*Queue) RemoveAll ¶ added in v1.0.0
RemoveAll removes all of the elements of the specified collection from this queue.
func (*Queue) RemoveListener ¶ added in v1.0.0
RemoveListener removes the specified listener.
func (*Queue) RetainAll ¶ added in v1.0.0
RetainAll removes the items which are not contained in the specified collection.
type QueueItemNotified ¶ added in v1.0.0
type QueueItemNotified struct { Value interface{} QueueName string Member cluster.MemberInfo 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context) error
Clear deletes all entries one by one and fires related events
func (*ReplicatedMap) ContainsKey ¶ added in v1.0.0
func (m *ReplicatedMap) ContainsKey(ctx context.Context, 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(ctx context.Context, 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
Destroy removes this object cluster-wide. Clears and releases all resources for this object.
func (*ReplicatedMap) Get ¶ added in v1.0.0
func (m *ReplicatedMap) Get(ctx context.Context, 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
GetEntrySet returns a clone of the mappings contained in this map.
func (*ReplicatedMap) GetKeySet ¶ added in v1.0.0
func (m *ReplicatedMap) GetKeySet(ctx context.Context) ([]interface{}, error)
GetKeySet returns keys contained in this map
func (*ReplicatedMap) GetValues ¶ added in v1.0.0
func (m *ReplicatedMap) GetValues(ctx context.Context) ([]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(ctx context.Context) (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(ctx context.Context, 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
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(ctx context.Context, key interface{}) (interface{}, error)
Remove deletes the value for the given key and returns it.
func (*ReplicatedMap) RemoveEntryListener ¶ added in v1.0.0
RemoveEntryListener removes the specified entry listener.
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
func (*Set) Add ¶ added in v1.0.0
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
AddAll adds the elements in the specified collection to this set. Returns true if the set is changed after the call.
func (*Set) AddListener ¶
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(ctx context.Context, 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) ContainsAll ¶ added in v1.0.0
ContainsAll returns true if the set includes all given values.
func (Set) Destroy ¶ added in v1.0.0
Destroy removes this object cluster-wide. Clears and releases all resources for this object.
func (*Set) Remove ¶ added in v1.0.0
Remove removes the specified element from the set if it exists.
func (*Set) RemoveAll ¶ added in v1.0.0
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
RemoveListener removes the specified listener.
type SetItemNotified ¶ added in v1.0.0
type SetItemNotified struct { Value interface{} SetName string Member cluster.MemberInfo 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 StatsConfig ¶ added in v1.0.0
type StatsConfig struct { // Enabled enables collecting statistics. Enabled bool // Period is the period of statistics collection. Period time.Duration }
StatsConfig contains configuration for Management Center.
func (StatsConfig) Validate ¶ added in v1.0.0
func (c StatsConfig) Validate() error
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 ¶
AddListener adds a subscriber to this topic.
func (Topic) Destroy ¶ added in v1.0.0
Destroy removes this object cluster-wide. Clears and releases all resources for this object.
func (*Topic) Publish ¶ added in v1.0.0
Publish publishes the given message to all subscribers of this topic.
func (*Topic) PublishAll ¶ added in v1.0.0
PublishAll published all given messages to all subscribers of this topic.
type TopicMessageHandler ¶ added in v1.0.0
type TopicMessageHandler func(event *MessagePublished)
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
examples
|
|
proto/codec
* Copyright (c) 2008-2021, Hazelcast, Inc.
|
* Copyright (c) 2008-2021, Hazelcast, Inc. |
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. |