All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vlingo.lattice.grid.spaces.Space Maven / Gradle / Ivy

Go to download

Tooling for reactive Domain-Driven Design projects that are highly concurrent. Includes compute grid, actor caching, spaces, cross-node cluster messaging, CQRS, and Event Sourcing support.

There is a newer version: 1.7.5
Show newest version
// Copyright © 2012-2020 VLINGO LABS. All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL
// was not distributed with this file, You can obtain
// one at https://mozilla.org/MPL/2.0/.

package io.vlingo.lattice.grid.spaces;

import java.time.Duration;
import java.util.Optional;

import io.vlingo.actors.Actor;
import io.vlingo.actors.ActorInstantiator;
import io.vlingo.common.Completes;

public interface Space {
   Completes itemFor(final Class protocol, final Class type, final Object...parameters);
   Completes> put(final Key key, final Item item);
   Completes>> get(final Key key, final Period until);
   Completes>> take(final Key key, final Period until);

  static class SpaceInstantiator implements ActorInstantiator {
    private static final long serialVersionUID = -9069272518290731677L;

    private final Duration defaultScanInterval;

    public SpaceInstantiator(final Duration defaultScanInterval) {
      this.defaultScanInterval = defaultScanInterval;
    }

    @Override
    public SpaceActor instantiate() {
      return new SpaceActor(defaultScanInterval);
    }

    @Override
    public Class type() {
      return SpaceActor.class;
    }
  }

  static class PartitioningSpaceRouterInstantiator implements ActorInstantiator {
    private static final long serialVersionUID = 5805822811311721096L;

    private final int totalPartitions;
    private final Duration defaultScanInterval;

    public PartitioningSpaceRouterInstantiator(final int totalPartitions, final Duration defaultScanInterval) {
      this.totalPartitions = totalPartitions;
      this.defaultScanInterval = defaultScanInterval;
    }

    @Override
    public PartitioningSpaceRouter instantiate() {
      return new PartitioningSpaceRouter(totalPartitions, defaultScanInterval);
    }

    @Override
    public Class type() {
      return PartitioningSpaceRouter.class;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy