Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 12 22:06
    jeremydmiller commented #575
  • Dec 12 21:51
    jeremydmiller commented #575
  • Dec 12 21:46
    jeremydmiller commented #575
  • Dec 12 21:43
    jeremydmiller commented #575
  • Dec 12 21:39
    jeremydmiller commented #575
  • Dec 12 21:14
    jeremydmiller opened #588
  • Dec 12 20:28
    jeremydmiller milestoned #587
  • Dec 12 20:28
    jeremydmiller opened #587
  • Dec 12 17:48
    jeremydmiller closed #583
  • Dec 12 17:48

    jeremydmiller on master

    improved message tracking and t… (compare)

  • Dec 12 17:46
    jeremydmiller commented #583
  • Dec 12 17:46
    jeremydmiller commented #583
  • Dec 12 17:01
    jeremydmiller commented #583
  • Dec 12 16:51
    jeremydmiller commented #583
  • Dec 12 16:51
    jeremydmiller commented #583
  • Dec 12 16:51
    jeremydmiller commented #583
  • Dec 12 16:37
    jeremydmiller commented #583
  • Dec 12 15:50
    jeremydmiller commented #583
  • Dec 12 15:45
    jeremydmiller commented #583
  • Dec 12 02:12
    Burwin closed #1407
Oskar Dudycz
@oskardudycz
I confirm :)
ddivita
@ddivita
When using Dependency Injection to instantiate a document session, what is the best way to inject a tenant id? Is it better to set the tenant after the session has been constructed? Is that possible by setting the session.Tenantproperty? I am using .Net Core 3 preview 7
Oskar Dudycz
@oskardudycz
@ddivita currently you need to pass it to the OpenSession initialization
we're considering making possibility to have it per operation or document, but at this moment you'd need to include it in the document session initialization in DI
services.Add(sp =>
            {
                var store = sp.GetService<DocumentStore>();
                var tenant = sp.GetService<ITenantProvider>();
                return store.OpenSession(tenant.TenantId);
            }, serviceLifetime);
something like that
ddivita
@ddivita
@oskardudycz , I figured as much. So with that said, what is the best approach to inject into a session. Considering the sessions are transient or scoped in the DI, we can pump in the tenant ID. I suppose I can pull the tenant ID off the logged in user or use a service to get the tenant
Oskar Dudycz
@oskardudycz
where ITenantProvider is your custom interface or other class that will return the tenant (eg. from http request)
ddivita
@ddivita
@oskardudycz , yep. That is what I was thinking!!!
Oskar Dudycz
@oskardudycz
:+1:
I personally was using that pattern in my application
ddivita
@ddivita
Awesome!! Good to know
Oskar Dudycz
@oskardudycz
:)
Matt Prigge
@mprigge
Are there any good examples of utilizing marten-based event sourcing in distributed systems? This may be a really basic question - I apologize for that. I am very new to Marten. I'm trying to determine how Service B would be able to read events generated by Service A in a read-only fashion (to build a read model which incorporates some of Service A's events). Is that kind of use case supported?
Oskar Dudycz
@oskardudycz
@mprigge I'm currently working on it in my sample repo https://github.com/oskardudycz/EventSourcing.NetCore
Matt Prigge
@mprigge
Oh, no kidding. Do you mean you're working on support for it or an example of how to implement it?
Oskar Dudycz
@oskardudycz
on example
it's ongoing, not yet finished
but basic integration with Kafka showing how to publis events from Marten through => MediatR (internal message Bus) => Kafka (External bus) => Elastic read model
it's already there
I'm also working on self-paced event sourcing training, basic exercies are already there also
Matt Prigge
@mprigge
Excellent. That's the sort of thing that really lets people jump into a new project. Great that you're doing that work! I will take a look. FWIW, I've found reading through your GoldenEye repo really useful as well.
Oskar Dudycz
@oskardudycz
Thank you :)
there is also sample there
but with non-distributed
If you have any questions feel free to ask here on on PM/email
If you have also some ideas suggestion what might be useful I'm also open :)
Matt Prigge
@mprigge
Thank you! That'e extremely kind of you to offer!
Jay Stevens
@jediwarpraptor
Good evening guys. Has anyone attempted to put a MongoDB wire-compatible gateway in front of Marten yet?
JT
@Hawxy
Hello, is there a preferred way to get a single document from a single tenant without setting the tenant in the session? I was thinking something like await _session.Query<TDocument>().Where(x => x.TenantIsOneOf(tenant) && x.Id == id).SingleOrDefaultAsync();
Jeremy D. Miller
@jeremydmiller
That’s an “I take pull requests” kind of question I think;)
And you’d want to do that outside of Linq to make it easier.
Babu Annamalai
@mysticmind
@Hawxy https://jasperfx.github.io/marten/documentation/documents/tenancy/basicoperations/ - you can examples of usage with and without passing tenant in session in the Default Tenancy section. Remember that if you did not pass tenant while creating a session, you may need to use TenantIsOneOf in all your LINQ queries.
Michael Lehto
@Leh2
What's the best way to determine if a document is deleted (when using soft deletes and using MaybeDeleted())? With version we have VersionedWith(x => x.Version), but can't find a equivalent for soft deletes.
Oskar Dudycz
@oskardudycz
@Leh2 Marten.Linq.SoftDeletes.MaybeDeleted or Marten.Linq.SoftDeletes.IsDeleted doesn't work?
Michael Lehto
@Leh2
Hi @oskardudycz, I'm querying with MaybeDeleted, but I want a property on the document reflecting the deleted state :)
Oskar Dudycz
@oskardudycz
you want to have that in the where selector? Or on the returned object? Because MaybeDeleted doesn't need any parameter to be queried, it should be fine to do x=> x.MaybeDeleted())
Tony Karalis
@tonykaralis
Morning all, having a bit of an issue with the AssertDatabaseMatches method. I output a DDL file, run the script in the database. then run the AssertDBMatches method expecting it to not throw an exception. Here is the output:
Message:   Expected: null
  But was:  <Marten.Schema.SchemaValidationException: Configuration to Schema Validation Failed! These changes detected:

-- data.mt_get_next_hi Diff
DROP FUNCTION data.mt_get_next_hi(entity character varying) cascade;

-- data.mt_get_next_hi Diff
CREATE OR REPLACE FUNCTION data.mt_get_next_hi(entity varchar) RETURNS int AS $$
DECLARE
    current_value bigint;
    next_value bigint;
BEGIN
    select hi_value into current_value from data.mt_hilo where entity_name = entity;
    IF current_value is null THEN
        insert into data.mt_hilo (entity_name, hi_value) values (entity, 0);
        next_value := 0;
    ELSE
        next_value := current_value + 1;
        update data.mt_hilo set hi_value = next_value where entity_name = entity;
    END IF;

    return next_value;
END
$$ LANGUAGE plpgsql;

   at Marten.Storage.TenantSchema.AssertDatabaseMatchesConfiguration()
   at MartenSchemaOps.SchemaValidator.AssertSchemaMatchesConfiguration()
   at DataSchema.Tests.SchemaValidation.AlignmentTests.Schema_Is_Valid() in

I have checked the DB and the following function exists:

-- FUNCTION: data.mt_get_next_hi(character varying)

-- DROP FUNCTION data.mt_get_next_hi(character varying);

CREATE OR REPLACE FUNCTION data.mt_get_next_hi(
    entity character varying)
    RETURNS integer
    LANGUAGE 'plpgsql'

    COST 100
    VOLATILE 
AS $BODY$
DECLARE
    current_value bigint;
    next_value bigint;
BEGIN
    select hi_value into current_value from data.mt_hilo where entity_name = entity;
    IF current_value is null THEN
        insert into data.mt_hilo (entity_name, hi_value) values (entity, 0);
        next_value := 0;
    ELSE
        next_value := current_value + 1;
        update data.mt_hilo set hi_value = next_value where entity_name = entity;
    END IF;

    return next_value;
END
$BODY$;

ALTER FUNCTION data.mt_get_next_hi(character varying)
    OWNER TO dbadmin;

Am I missing something? I tried running the patch but that doesn't help either. I have not installed anything to get hilo working as i don't use it. Do I need to?

Michael Lehto
@Leh2
@oskardudycz Yes exactly: "Or on the returned object?" :)
Oskar Dudycz
@oskardudycz
@Leh2 I think that there is no built in, but if you add to your document type property IsDeleted then imho it should be reflected in the result
@tonykaralis could you provide your DocumentStore config?
Tony Karalis
@tonykaralis
@oskardudycz sure
 var options = new StoreOptions
            {                    
                AutoCreateSchemaObjects = AutoCreate.None,
                DatabaseSchemaName = schema,
                //plv8 used for the patching api, only works if plv8 installed.
                PLV8Enabled = false
            };

            //configure the ddl script generated
            options.DdlRules.TableCreation = CreationStyle.CreateIfNotExists;

            //critical to deserializing interfaces etc
            options.Serializer(SetupCustomSerializer(customBinder));

            #region Helper object setup
            options.Schema.For<BoostOption>();
            options.Schema.For<Country>();
            options.Schema.For<Tool>();
            options.Schema.For<BenchMark>().ForeignKey<Project>(x => x.ProjectId);
            #endregion

            #region Terms
            options.Schema.For<BullseyeTerm>();
            options.Schema.For<PccCompetitor>().ForeignKey<BrandCategory>(x => x.BrandCategoryId)
                                        .ForeignKey<Country>(x => x.CountryId);
            options.Schema.For<CategoryTerm>().ForeignKey<BrandCategory>(x => x.BrandCategoryId);
            options.Schema.For<DistractorImage>().ForeignKey<BrandCategory>(x => x.BrandCategoryId)
                                        .ForeignKey<Country>(x => x.CountryId);
            #endregion

            #region Brand
            options.Schema.For<BrandCategory>();
            options.Schema.For<IBrand>().AddSubClassHierarchy(typeof(Brand))
                                  .ForeignKey<BrandCategory>(x => x.BrandCategoryId)
                                  .ForeignKey<Country>(x => x.CountryId);
            #endregion

            #region Items
            options.Schema.For<ItemCategory>();
            options.Schema.For<IItem>().AddSubClassHierarchy(typeof(Item))
                               .ForeignKey<Project>(x => x.ProjectId)
                               .ForeignKey<Country>(x => x.CountryId)
                               .UseOptimisticConcurrency(true);

            options.Schema.For<ItemTagCategory>();
            options.Schema.For<ItemTag>().ForeignKey<ItemTagCategory>(x => x.ItemTagCategoryId);
            #endregion

            #region Project Setup
            options.Schema.For<Quote>();
            options.Schema.For<ProjectStatus>();
            options.Schema.For<ProjectBrand>();
            options.Schema.For<Project>().ForeignKey<ProjectStatus>(x => x.ProjectStatusId)
                                           .ForeignKey<Quote>(x => x.QuoteId)
                                           .UseOptimisticConcurrency(true)
                                           .FullTextIndex();
            options.Schema.For<ProjectTaskManager>().ForeignKey<Project>(x => x.ProjectId);
            #endregion

            #region Survey Setup
            options.Schema.For<SurveyStatus>();
            options.Schema.For<Survey>().ForeignKey<SurveyStatus>(x => x.SurveyStatusId)
                                  .ForeignKey<Project>(x => x.ProjectId)
                                  .Duplicate(x => x.ProjectNumber);
            #endregion

            #region Idataquestion Setup
            options.Schema.For<RespondentIdMapping>().ForeignKey<Survey>(x => x.SurveyId)
                                               .ForeignKey<Project>(x => x.ProjectId)
                                               .ForeignKey<Country>(x => x.MarketId);

            options.Schema.For<IQuestionData>().AddSubClassHierarchy(DocumentStoreConfigExtensions.GetQuestionDataTypes())
                                                                .ForeignKey<Survey>(x => x.SurveyId)
                                                                .ForeignKey<Country>(x => x.CountryId)
                                                                .ForeignKey<RespondentIdMapping>(x => x.RespMapId)
                                                                .UseOptimisticConcurrency(true);
            #endregion

            #region BaseCos
Most classes use Guid, only a couple use int as Id's.
Michael Lehto
@Leh2
image.png
@oskardudycz tried the following but with no luck :(
Oskar Dudycz
@oskardudycz
@tonykaralis ok, I'll try to check that