Skip to content

Instantly share code, notes, and snippets.

View aludwiko's full-sized avatar

Andrzej Ludwikowski aludwiko

View GitHub Profile
./sstabledump ~/.ccm/test/node1/data0/my_keyspace/orders-8b2e7e2022d111e9abc5abfbe212c0f3/mc-1-big-Data.db
[
{
"partition" : {
"key" : [ "1" ],
"position" : 0
},
"rows" : [
{
"type" : "row",
INSERT INTO orders (id, status, country) VALUES ( 1, 'added', 'PL');
INSERT INTO orders (id, status, country) VALUES ( 1, 'verified', 'PL');
INSERT INTO orders (id, status, country) VALUES ( 1, 'shipped', 'PL');
CREATE TABLE orders (
id int,
status text,
country text,
PRIMARY KEY (id)
);
final case class UserCreatedEvent(
userId: String = "",
operationId: String = "",
createdAt: Long = 0L,
name: String = "",
email: String = ""
)
"PackageStructureValidation" should "check no dependency from domain to application" in {
// given
val rule = noClasses().that().resideInAPackage("..domain..").should().accessClassesThat().resideInAPackage("..application..")
// when // then
rule.check(classes)
}
it should "check no dependency from domain to akka framework" in {
final case class User private[domain] (userId: UserId, createdAt: Instant, name: String, email: Email) {
def applyEvent(userEvent: UserEvent): Try[User] = userEvent match {
case _: UserCreated => Failure(new IllegalStateException("User already created. Event cannot be applied."))
case event: NameUpdated => Success(copy(name = event.newName))
case event: EmailUpdated => Success(copy(email = event.newEmail))
}
def process(userCommand: UserCommand): Try[List[UserEvent]] = userCommand match {
case _: CreateUser => Failure(new IllegalStateException("User already created. Command cannot be processed."))
import javax.persistence.*;
import java.util.List;
import static java.util.Collections.unmodifiableList;
import static javax.persistence.GenerationType.AUTO;
@Entity
public class Issue {
@EmbeddedId
import org.axonframework.commandhandling.CommandHandler;
import org.axonframework.commandhandling.model.AggregateIdentifier;
import org.axonframework.eventsourcing.EventSourcingHandler;
import org.axonframework.samples.trader.api.users.*;
import org.axonframework.samples.trader.users.util.DigestUtils;
import org.axonframework.spring.stereotype.Aggregate;
import static org.axonframework.commandhandling.model.AggregateLifecycle.apply;
@Aggregate(repository = "userAggregateRepository")
import akka.Done
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag, AggregateEventTagger, PersistentEntity}
import play.api.libs.json.{Format, Json}
import com.example.auction.utils.JsonFormats._
import com.lightbend.lagom.scaladsl.api.transport.{TransportErrorCode, TransportException}
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity.ReplyType
class AuctionEntity extends PersistentEntity {
import AuctionStatus._
...
val eventJournal = PersistenceQuery(system).readJournalFor[CassandraReadJournal](CassandraReadJournal.Identifier)
eventJournal
.eventsByPersistenceId(persistenceId, startingSequenceNr, Long.MaxValue)
.via(updateSingleReadModel)
.mapAsync(1)(saveSequnceNr)