public void Start() { if (EmbeddedEventStoreConfiguration.RunWithLogging) { if (!Directory.Exists(EmbeddedEventStoreConfiguration.LogPath)) Directory.CreateDirectory(EmbeddedEventStoreConfiguration.LogPath); LogManager.Init(string.Format("as-embed-es-{0}", DateTime.Now.Ticks), EmbeddedEventStoreConfiguration.LogPath); } var db = CreateTFChunkDb(EmbeddedEventStoreConfiguration.StoragePath); var settings = CreateSingleVNodeSettings(); _node = new SingleVNode(db, settings, false, 0xf4240, new ISubsystem[0]); var waitHandle = new ManualResetEvent(false); _node.MainBus.Subscribe(new AdHocHandler<SystemMessage.BecomeMaster>(m => waitHandle.Set())); _node.Start(); waitHandle.WaitOne(); _credentials = new UserCredentials("admin", "changeit"); _connection = EventStoreConnection.Create( ConnectionSettings.Create(). EnableVerboseLogging(). SetDefaultUserCredentials(_credentials). UseConsoleLogger(), TcpEndPoint); _connection.Connect(); }
protected override void Given() { var creds = new UserCredentials("admin", "changeit"); DeletedStreamName = Guid.NewGuid().ToString(); LinkedStreamName = Guid.NewGuid().ToString(); using (var conn = TestConnection.Create(_node.TcpEndPoint)) { conn.ConnectAsync().Wait(); conn.AppendToStreamAsync(DeletedStreamName, ExpectedVersion.Any, creds, new EventData(Guid.NewGuid(), "testing1", true, Encoding.UTF8.GetBytes("{'foo' : 4}"), new byte[0])) .Wait(); conn.SetStreamMetadataAsync(DeletedStreamName, ExpectedVersion.Any, new StreamMetadata(2, null, null, null, null)).Wait(); conn.AppendToStreamAsync(DeletedStreamName, ExpectedVersion.Any, creds, new EventData(Guid.NewGuid(), "testing2", true, Encoding.UTF8.GetBytes("{'foo' : 4}"), new byte[0])) .Wait(); conn.AppendToStreamAsync(DeletedStreamName, ExpectedVersion.Any, creds, new EventData(Guid.NewGuid(), "testing3", true, Encoding.UTF8.GetBytes("{'foo' : 4}"), new byte[0])) .Wait(); conn.AppendToStreamAsync(LinkedStreamName, ExpectedVersion.Any, creds, new EventData(Guid.NewGuid(), SystemEventTypes.LinkTo, false, Encoding.UTF8.GetBytes("0@" + DeletedStreamName), new byte[0])).Wait(); } }
protected override void Given() { UserCredentials = new UserCredentials("dFine", "Password02"); Connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113)); EventFactory = new EventFactory(UserCredentials, Connection); }
public static void Configure(ProjectionGatewayConfiguration projectionGatewayConfiguration, IPEndPoint httpEndPoint, UserCredentials credentials) { var projectionManager = new ProjectionsManager(new ConsoleLogger(), httpEndPoint, new TimeSpan(1, 0, 0, 0)); var byCategoryProjectionStatus = ((JObject)JsonConvert.DeserializeObject(projectionManager.GetStatusAsync("$by_category", credentials).Result))["status"].ToString(); var streamByCategoryProjectionStatus = ((JObject)JsonConvert.DeserializeObject(projectionManager.GetStatusAsync("$stream_by_category", credentials).Result))["status"].ToString(); if (byCategoryProjectionStatus == "Stopped") { projectionManager.EnableAsync("$by_category", credentials).Wait(); } if (streamByCategoryProjectionStatus == "Stopped") { projectionManager.EnableAsync("$stream_by_category", credentials).Wait(); } const string projectionPattern = @"fromCategory('{0}') .foreachStream() .whenAny(function(state, event){{ linkTo('{1}', event); }})"; foreach (var aggregateRootName in projectionGatewayConfiguration.Subscriptions.Keys) { projectionManager.CreateContinuousAsync( string.Format("{0}Projection", aggregateRootName), string.Format(projectionPattern, aggregateRootName, aggregateRootName + "View"), credentials).Wait(); } }
public void CreateContinuous(string name, string query, UserCredentials userCredentials = null) { Ensure.NotNullOrEmpty(name, "name"); Ensure.NotNullOrEmpty(query, "query"); CreateContinuousAsync(name, query, userCredentials).Wait(); }
static void Main(string[] args) { var endpoint = new IPEndPoint(IPAddress.Loopback, 1113); var esCon = EventStoreConnection.Create(endpoint); esCon.Connect(); var credentials = new UserCredentials("admin", "changeit"); var adapter = new EventStoreAdapter(endpoint, credentials); //var cm = new CommandManager(esCon); //var pm = new ProjectionManager(endpoint, credentials, adapter); //pm.Run(); //var cp = new MyDiagProjection(endpoint, credentials, adapter, "Budgets-1722f4ea_a9a5_4d97_8c39_c9d450a1331a"); //cp.Start(); //while (cp.HasLoaded == false) // System.Threading.Thread.Sleep(100); //Console.WriteLine("done from all"); //Console.ReadLine(); var cp2 = new BudgetLinesProjection("Budgets-1722f4ea_a9a5_4d97_8c39_c9d450a1331a", endpoint, credentials, adapter, "lines_of_Budgets-1722f4ea_a9a5_4d97_8c39_c9d450a1331a" ); cp2.Start(); //var cp2 = new MyDiagProjection(endpoint, credentials, adapter, "Budgets-1722f4ea_a9a5_4d97_8c39_c9d450a1331a", "lines_of_Budgets-1722f4ea_a9a5_4d97_8c39_c9d450a1331a"); //cp2.Start(); while (cp2.HasLoaded == false) System.Threading.Thread.Sleep(100); Console.ReadLine(); //var events = adapter.GetStreamEvents(""); }
public SubscriptionOperation(ILogger log, TaskCompletionSource<EventStoreSubscription> source, string streamId, bool resolveLinkTos, UserCredentials userCredentials, Action<EventStoreSubscription, ResolvedEvent> eventAppeared, Action<EventStoreSubscription, SubscriptionDropReason, Exception> subscriptionDropped, bool verboseLogging, Func<TcpPackageConnection> getConnection) { Ensure.NotNull(log, "log"); Ensure.NotNull(source, "source"); Ensure.NotNull(eventAppeared, "eventAppeared"); Ensure.NotNull(getConnection, "getConnection"); _log = log; _source = source; _streamId = string.IsNullOrEmpty(streamId) ? string.Empty : streamId; _resolveLinkTos = resolveLinkTos; _userCredentials = userCredentials; _eventAppeared = eventAppeared; _subscriptionDropped = subscriptionDropped ?? ((x, y, z) => { }); _verboseLogging = verboseLogging; _getConnection = getConnection; }
protected EventStoreCatchUpSubscription(IEventStoreConnection connection, ILogger log, string streamId, bool resolveLinkTos, UserCredentials userCredentials, Action<EventStoreCatchUpSubscription, ResolvedEvent> eventAppeared, Action<EventStoreCatchUpSubscription> liveProcessingStarted, Action<EventStoreCatchUpSubscription, SubscriptionDropReason, Exception> subscriptionDropped, bool verboseLogging, int readBatchSize = DefaultReadBatchSize, int maxPushQueueSize = DefaultMaxPushQueueSize) { Ensure.NotNull(connection, "connection"); Ensure.NotNull(log, "log"); Ensure.NotNull(eventAppeared, "eventAppeared"); Ensure.Positive(readBatchSize, "readBatchSize"); Ensure.Positive(maxPushQueueSize, "maxPushQueueSize"); _connection = connection; Log = log; _streamId = string.IsNullOrEmpty(streamId) ? string.Empty : streamId; _resolveLinkTos = resolveLinkTos; _userCredentials = userCredentials; ReadBatchSize = readBatchSize; MaxPushQueueSize = maxPushQueueSize; EventAppeared = eventAppeared; _liveProcessingStarted = liveProcessingStarted; _subscriptionDropped = subscriptionDropped; Verbose = verboseLogging; }
public static void Start() { var node = EmbeddedVNodeBuilder. AsSingleNode(). OnDefaultEndpoints(). RunInMemory(). Build(); node.Start(); var tcs = new TaskCompletionSource<object>(); node.NodeStatusChanged += (sender, args) => { if (args.NewVNodeState == VNodeState.Master) tcs.SetResult(null); }; tcs.Task.Wait(); Node = node; Credentials = new UserCredentials("admin", "changeit"); var connection = EmbeddedEventStoreConnection.Create(Node); // This does not work, because ... ††† JEZUS ††† //var connection = EventStoreConnection.Create( // ConnectionSettings.Create().SetDefaultUserCredentials(Credentials).UseDebugLogger(), // new IPEndPoint(Opts.InternalIpDefault, Opts.ExternalTcpPortDefault)); connection.ConnectAsync().Wait(); Connection = connection; }
/// <summary> /// Constructs a new <see cref="EventStoreTransaction"/> /// </summary> /// <param name="transactionId">The transaction id of the transaction</param> /// <param name="userCredentials">User credentials under which transaction is committed.</param> /// <param name="connection">The connection the transaction is hooked to</param> internal EventStoreTransaction(long transactionId, UserCredentials userCredentials, IEventStoreTransactionConnection connection) { Ensure.Nonnegative(transactionId, "transactionId"); TransactionId = transactionId; _userCredentials = userCredentials; _connection = connection; }
public BudgetProjection(Budget budget, IPEndPoint endpoint, UserCredentials credentials, IAdaptEvents adapter, string stream) : base(endpoint, credentials, adapter, stream) { _budget = budget; _checkPoints = new Dictionary<string, CheckPoint>(); _lines = new List<BudgetLine>(); }
public ProjectionManager(IPEndPoint endpoint, UserCredentials credentials, IAdaptEvents adapter) { _adapter = adapter; _endpoint = endpoint; _credentials = credentials; _budgetLines = new Dictionary<string, BudgetLinesProjection>(); _budget = new Dictionary<string, BudgetProjection>(); }
public Task CreateTransient(IPEndPoint endPoint, string name, string query, UserCredentials userCredentials = null) { return SendPost( endPoint.ToHttpUrl("/projections/transient?name={0}&type=JS", name), query, userCredentials, HttpStatusCode.Created); }
public Task<DeleteResult> DeleteStreamAsync(string stream, int expectedVersion, bool hardDelete, UserCredentials userCredentials = null) { Ensure.NotNullOrEmpty(stream, "stream"); var source = new TaskCompletionSource<DeleteResult>(); EnqueueOperation(new DeleteStreamOperation(_settings.Log, source, _settings.RequireMaster, stream, expectedVersion, hardDelete, userCredentials)); return source.Task; }
public EventStore(IPEndPoint endpoint, UserCredentials credentials, IAdaptEvents adapter) { _endpoint = endpoint; _credentials = credentials; _adapter = adapter; _con = EventStoreConnection.Create(endpoint); _con.Connect(); }
public OuroStreamFactory( ILogger<IEventStore> logger, IEventStoreConnection eventStore, UserCredentials credentials) { _logger = logger; _eventStore = eventStore; _credentials = credentials; }
public void Delete(string url, UserCredentials userCredentials, Action<HttpResponse> onSuccess, Action<Exception> onException) { Ensure.NotNull(url, "url"); Ensure.NotNull(onSuccess, "onSuccess"); Ensure.NotNull(onException, "onException"); Receive(HttpMethod.Delete, url, userCredentials, onSuccess, onException); }
public EventFactory(UserCredentials credentials, IEventStoreConnection connection) { _closedEvent = new ClosedEvent(credentials, connection); _openedEvent = new OpenedEvent(credentials, connection); _registerBreakerEvent = new RegisterBreakerEvent(credentials, connection); _tryingToCloseEvent = new TryingToCloseEvent(credentials, connection); _unregisterBreakerEvent = new UnregisterBreakerEvent(credentials, connection); _tolleratedOpenEvent = new TolleratedOpenEvent(credentials, connection); }
public static Repository<User> Create(UnitOfWork unitOfWork, IEventStoreConnection connection, UserCredentials credentials) { return new Repository<User>(() => User.Factory(), unitOfWork, connection, new EventReaderConfiguration( new SliceSize(512), new JsonDeserializer(), new PassThroughStreamNameResolver(), new FixedStreamUserCredentialsResolver(credentials))); }
public void Get(string url, UserCredentials userCredentials, TimeSpan timeout, Action<HttpResponse> onSuccess, Action<Exception> onException) { Ensure.NotNull(url, "url"); Ensure.NotNull(onSuccess, "onSuccess"); Ensure.NotNull(onException, "onException"); Receive(HttpMethod.Get, url, userCredentials, timeout, onSuccess, onException); }
public void Get(string url, UserCredentials userCredentials, Action<HttpResponse> onSuccess, Action<Exception> onException, string hostHeader = "") { Ensure.NotNull(url, "url"); Ensure.NotNull(onSuccess, "onSuccess"); Ensure.NotNull(onException, "onException"); Receive(HttpMethod.Get, url, userCredentials, onSuccess, onException, hostHeader); }
public Task<UserDetails> GetUser(IPEndPoint endPoint, string login, UserCredentials userCredentials = null) { return SendGet(endPoint.ToHttpUrl("/users/{0}", login), userCredentials, HttpStatusCode.OK) .ContinueWith(x => { if (x.IsFaulted) throw x.Exception; var r = JObject.Parse(x.Result); return r["data"] != null ? r["data"].ToObject<UserDetails>() : null; }); }
public void HandleUserCommands() { IEventStoreConnection connection = null; var credentials = new UserCredentials("admin", "changeit"); var unitOfWork = new UnitOfWork(); var repository = RepositoryFactory.Create(unitOfWork, connection, credentials); //ICommandHandler<CreateBasicUser> handler = new CreateBasicUserCommandHandler(connection, repository, unitOfWork); //handler.HandleCommand(); }
public Task<List<ProjectionDetails>> ListOneTime(IPEndPoint endPoint, UserCredentials userCredentials = null) { return SendGet(endPoint.ToHttpUrl("/projections/onetime"), userCredentials, HttpStatusCode.OK) .ContinueWith(x => { if (x.IsFaulted) throw x.Exception; var r = JObject.Parse(x.Result); return r["projections"] != null ? r["projections"].ToObject<List<ProjectionDetails>>() : null; }); }
protected override void Given() { var creds = new UserCredentials("admin", "changeit"); LinkedStreamName = Guid.NewGuid().ToString(); DeletedStreamName = Guid.NewGuid().ToString(); _conn.AppendToStreamAsync(DeletedStreamName, ExpectedVersion.Any, creds, new EventData(Guid.NewGuid(), "testing", true, Encoding.UTF8.GetBytes("{'foo' : 4}"), new byte[0])).Wait(); _conn.AppendToStreamAsync(LinkedStreamName, ExpectedVersion.Any, creds, new EventData(Guid.NewGuid(), SystemEventTypes.LinkTo, false, Encoding.UTF8.GetBytes("0@" + DeletedStreamName), new byte[0])).Wait(); _conn.DeleteStreamAsync(DeletedStreamName, ExpectedVersion.Any).Wait(); }
internal override Task<PersistentEventStoreSubscription> StartSubscription( string subscriptionId, string streamId, int bufferSize, UserCredentials userCredentials, Action<EventStoreSubscription, ResolvedEvent> onEventAppeared, Action<EventStoreSubscription, SubscriptionDropReason, Exception> onSubscriptionDropped, ConnectionSettings settings) { var source = new TaskCompletionSource<PersistentEventStoreSubscription>(); _handler.EnqueueMessage(new StartPersistentSubscriptionMessage(source, subscriptionId, streamId, bufferSize, userCredentials, onEventAppeared, onSubscriptionDropped, settings.MaxRetries, settings.OperationTimeout)); return source.Task; }
public void Post(string url, string body, string contentType, TimeSpan timeout, UserCredentials userCredentials, Action<HttpResponse> onSuccess, Action<Exception> onException) { Ensure.NotNull(url, "url"); Ensure.NotNull(body, "body"); Ensure.NotNull(contentType, "contentType"); Ensure.NotNull(onSuccess, "onSuccess"); Ensure.NotNull(onException, "onException"); Send(HttpMethod.Post, url, body, contentType, userCredentials, timeout, onSuccess, onException); }
private void Connect() { var settings = ConnectionSettings.Create(); var ip = new IPEndPoint(_ipAddress, _port); Log("Connecting to {0}:{1}...", _ipAddress, _port); _connection = EventStoreConnection.Create(settings, ip); _connection.ConnectAsync(); _connection.AppendToStreamAsync("hello", ExpectedVersion.Any, new EventData(Guid.NewGuid(), "Hello", false, new byte[0], new byte[0])); Log("Connected."); Log("Username to be used is: {0}", _userName); _credentials = new UserCredentials(_userName, _password); }
public EventStoreUnitOfWorkHandler() { var credentials = new UserCredentials("admin", "changeit"); _connection = EventStoreConnection.Create( ConnectionSettings.Create(). UseConsoleLogger(). SetDefaultUserCredentials( credentials), new IPEndPoint(IPAddress.Loopback, 1113), "UserServiceConnection"); _connection.Connect(); }
public OuroSellerEndpointAdapter(IEventStoreConnection connection, string adapterName, IOuroSellerEndpoint endpoint, string incomingStream, UserCredentials credentials=null) { _connection = connection; _adapterName = adapterName; _endpoint = endpoint; _incomingStream = incomingStream; _credentials = credentials; }