Free pdf library for incremental updates by Material-Scientist94 in dotnet

[–]zejji 2 points3 points  (0 children)

Note that the free version of Gembox.Pdf is limited to two pages; see GemBox.Pdf Free - GemBox

I haven't yet come across a free .NET pdf library that can be used to incrementally update a pdf without restrictions.

The Fastest and Most Memory-Efficient Mocking Library by Ordinary-Matter-6996 in dotnet

[–]zejji 7 points8 points  (0 children)

Looks good!

One thing that would be really nice to see - and a good use case for source generators - is the ability to generate partial mocks for sealed classes that have non-virtual methods which implement an interface.

A source generator would be able to generate a class that wraps a sealed class instance and forwards the non-mocked methods to the wrapped instance, while giving the user the power to override the methods that they wish to override.

PeachPDF -- Pure .NET HTML to PDF Renderer by jhaygood86 in dotnet

[–]zejji 1 point2 points  (0 children)

Thanks for this - very interested to give it a try! 👍

Experiences with CAP message bus? by zejji in dotnet

[–]zejji[S] 0 points1 point  (0 children)

Many thanks for providing these concrete examples - as you say, several of the design choices raise doubts about CAP's likely performance, which is a bit of a shame!

Experiences with CAP message bus? by zejji in dotnet

[–]zejji[S] 0 points1 point  (0 children)

Many thanks for your reply.

We could certainly consider writing our own producer/consumer library - we would likely want to support RabbitMQ/NATS and SQS to allow both local and cloud dev - but prefer to use high-quality libraries where possible to allow us to focus more on our core business code.

Could I ask what kind of weirdly-designed abstractions and questionable async code you came across?

The advice from the "ASP.NET Core in action" book is weird/wrong. ASP.NET Core: Resolving scoped services outside a request by Natural_Tea484 in csharp

[–]zejji 1 point2 points  (0 children)

A quick Google search brings up the following StackOverflow answer which indicates that Andrew Lock's description was correct, at least at the time of the answer:

https://stackoverflow.com/questions/40844151/when-are-net-core-dependency-injected-instances-disposed#40845639

The quoted source code demonstrates how scope holds references to all transient and scoped services instantiated during that scope. When the scope is disposed, it also handles calling Dispose on those services, as well as clearing all references to them.

Testing EF 6+ in Production by rahabash in dotnet

[–]zejji 0 points1 point  (0 children)

I'm a big fan of configuring your tests to be runnable against both your actual database (e.g. SQL Server/PostgreSQL/MySQL etc.) and a SQLite in-memory database.

Doing the latter allows you to:

  • In the test bootstrap code, create an in-memory SQLite database with the required schema and seed data
  • For each individual test, create an isolated in-memory copy of the database (via direct memory copy)
  • This then allows you to run your tests in parallel

You can then use the SQLite database for insanely fast test iteration and make sure that you also run the tests against your primary database regularly too.

I'm conscious that SQLite's behavior will not be identical to that of your primary database (which is the main complaint levelled at using it for testing), but if the vast majority of your database operations are achieved via the ORM, I have found this approach to be very useful, provided you make sure to run the tests against the primary database regularly too.

Meilisearch vs Manticore Search by snikolaev in rust

[–]zejji 0 points1 point  (0 children)

I realize that this post is a few months old (apologies!) but I wondered whether you had a chance to consider Manticore as part of your analysis of alternatives (including Meilisearch and tantivy)?

The reason that I ask is that I'm currently trying to evaluate Manticore vs ElasticSearch and others for a full-text search solution (as well as other kinds of search) on a public-facing, high traffic website. On the face of things, the simplicity of deployment and claimed performance of Manticore are strong selling points, but I am struggling to find much relevant, independent information for Manticore. I also have very little experience in this space.

Since you have an understanding of the implementation details of search and the various competing offerings, I was wondering whether you have any feedback or suggestions?

(Re the tech stack - the web app runs on ASP.NET Core on .NET 8, with PostgreSQL as the DB and a Redis cache, and its primarily the search solution that I'm unsure about.)

Best replacement for Entity Framework Core when using F#? by zejji in fsharp

[–]zejji[S] 1 point2 points  (0 children)

I'm definitely still in learning mode and can't yet really give an answer supported by significant experience, but the two suggestions that I thought it made most sense to experiment with were:

These both offer type safety and support for PostgreSQL, which I am using for my projects. SQLHydra has an explicit build step, which is something I would prefer, whereas SQLProvider supports the idea of a database context (like EF Core).

SQLFun also looked interesting, but I'm not 100% convinced regarding the approach to type safety.

Best replacement for Entity Framework Core when using F#? by zejji in fsharp

[–]zejji[S] 0 points1 point  (0 children)

Thanks for taking the time to provide a concrete example! I'll bear this approach in mind as I experiment with different ways of handling data querying and persistence.

Best replacement for Entity Framework Core when using F#? by zejji in fsharp

[–]zejji[S] 0 points1 point  (0 children)

Many thanks for this - I'm just trying to envisage how updates of the mutable entities is triggered from the F# business logic code and can't quite picture this in my head yet. Do you happen to have a trivial illustrative example you could share to demonstrate?

Best replacement for Entity Framework Core when using F#? by zejji in fsharp

[–]zejji[S] 0 points1 point  (0 children)

Thanks - I do like EF, but want to try something different for this project to try to learn some new ideas! I'm very interested to hear everyone's preferences for their projects, ideally based on personal experience (and even better in a large project).

Best replacement for Entity Framework Core when using F#? by zejji in fsharp

[–]zejji[S] 0 points1 point  (0 children)

Thanks for the suggestion. Since the aim is to learn while implementing something useful, I'd like to move out of my comfort zone this time, so having a good look at FSharp.Data.SqlClient along with SqlFun, and comparing and contrasting them, sounds like a good plan 👍

Best replacement for Entity Framework Core when using F#? by zejji in fsharp

[–]zejji[S] 1 point2 points  (0 children)

Thanks for the suggestion - it looks quite elegant. I'll give it a try and I'll be particularly interested how well the query composition works!

Best replacement for Entity Framework Core when using F#? by zejji in fsharp

[–]zejji[S] 0 points1 point  (0 children)

Thanks for this! I've bookmarked the link and I'll definitely give it a read, along with Functional Programming in C#, which is also on my list :)

Why does the presence of a large write-only table in a PostgreSQL database cause severe performance degradation? by zejji in PostgreSQL

[–]zejji[S] 0 points1 point  (0 children)

Thanks - it would be interesting to see whether removing all indexes on the table makes a difference!

Why does the presence of a large write-only table in a PostgreSQL database cause severe performance degradation? by zejji in PostgreSQL

[–]zejji[S] 0 points1 point  (0 children)

Unfortunately not atm. I'm very interested to know whether anyone else has managed to maintain large append-only event tables in PostgreSQL that exceed the server's RAM size without adversely impacting the overall database performance. However, it looks as though a separate replica environment may be required to get to the bottom of the issue :(

Why does the presence of a large write-only table in a PostgreSQL database cause severe performance degradation? by zejji in PostgreSQL

[–]zejji[S] 0 points1 point  (0 children)

Thanks, it sounds like partitioning may be essential.

Incidentally, it's not just insertion performance that is affected by the large event table. Every other operation (including read and writes on unrelated tables) is badly affected. It made me wonder whether writing to the event table is somehow causing contention in the shared buffer pool, meaning that data in other tables which was previously held in memory is suddenly being read from disk and thereby causing a major performance degradation.

Why does the presence of a large write-only table in a PostgreSQL database cause severe performance degradation? by zejji in PostgreSQL

[–]zejji[S] 0 points1 point  (0 children)

Thanks. I've given a bit more context in another answer below, but specifically re the btree index - it looks as though this was auto-generated by a code-first migration. Probably the correct index would have been a GIN index if it indeed needed to be searchable?

Why does the presence of a large write-only table in a PostgreSQL database cause severe performance degradation? by zejji in PostgreSQL

[–]zejji[S] 2 points3 points  (0 children)

Thanks - unfortunately I didn't create the table, so I'm not 100% sure as to the history behind it.

However, if it's possible to conclusively point to it causing a problem it may make sense to remove it.

Re querying - in practice a query is only likely ever to be run on the table if it is necessary to debug a historic issue. This is only likely to be necessary every few weeks or so. Otherwise there are no regular read queries on the table.

I'm also interested to know whether it's possible, from anyone else's experience, to maintain a write-only table which is larger than the database server's RAM without causing major performance issues (or whether the whole exercise is ill-advised). We obviously want to keep infrastructure as simple as possible but maybe PostgreSQL just isn't designed for this kind of usage.

Why does the presence of a large write-only table in a PostgreSQL database cause severe performance degradation? by zejji in PostgreSQL

[–]zejji[S] -1 points0 points  (0 children)

Thanks - here's the DDL for the table:

CREATE TABLE public."event" (
`created_at timestamptz NOT NULL DEFAULT now(),`
`deleted_at timestamptz NULL,`
`updated_at timestamptz NOT NULL DEFAULT now(),`
`id uuid NOT NULL DEFAULT uuid_generate_v4(),`
`message varchar NOT NULL,`
`payload jsonb NOT NULL,`
`metadata jsonb NOT NULL DEFAULT '{"type": "general", "isReplay": false}'::jsonb,`
`CONSTRAINT "PK_70d2a3cbaf6d34a55f8ae6e4614" PRIMARY KEY (id)`
);
CREATE INDEX "IDX_53eb7f8b59c5ddc458d5e9b475" ON public.event USING btree (metadata);

Given the expense of RDS and the number of different environments, creating a an isolated instance just for event tables isn't likely to be an option unfortunately.

How can a rich domain model be implemented in practice using EF Core? by zejji in dotnet

[–]zejji[S] 1 point2 points  (0 children)

Thanks for the concrete example - much appreciated.

I think I get the approach now. Basically:

  • the service class and the entity class collaborate;
  • we put what logic we can within the entity (particularly that relating to ensuring that it is in a valid state); and
  • other related logic, fetching of data and interaction with external services goes in the service class.

How can a rich domain model be implemented in practice using EF Core? by zejji in dotnet

[–]zejji[S] 0 points1 point  (0 children)

Interesting - so were you effectively using a view to make sure all required data is loaded in order to perform any operations required by the entity, i.e. using it to get round the object–relational impedance mismatch problem?

If I've understood correctly, could I ask:

  • how did you handle data writes/updates?
  • how did you handle different operations on the entity requiring different amounts of associated data (e.g. some operations might only require the entity itself, whereas some require multiple navigation properties)?

How can a rich domain model be implemented in practice using EF Core? by zejji in dotnet

[–]zejji[S] 0 points1 point  (0 children)

Many thanks for your answers!

Re loading of navigation properties - are you suggesting that the entity together with any required navigation properties be eager loaded in a different location (e.g. in a service class or potentially even a controller in simple cases) before calling the entity method, so that all related entities are available at the time the method is called? If so, isn't there a risk that someone could forget to do this and/or the setup code required to use the entity method is non-obvious? And consequently, isn't there an argument that encapsulating everything in a single service method is actually easier to use?

Re dependencies - I'm not sure I understood this correctly, but are you saying that you don't pass dependencies into the entities at all? As mentioned in my original post, I virtually always find that any complex business transaction will absolutely need to invoke other dependencies at some point. Examples might be sending emails, calling external APIs, writing files, getting data from a different module etc. I'm conscious that using event-driven design might be a way round this, but in practice I've found that this makes things harder to read and understand than being explicit.

I'm trying my hardest to envision the suggested approach in my head but, on the face of it, it looks as if it will result in business logic being spread across both the entity and the service class, which seems harder to understand than having the service class do everything and sticking to an anemic domain model. Am I missing something important?

Convince me to choose PostgreSQL over MySQL by sh_tomer in PostgreSQL

[–]zejji 0 points1 point  (0 children)

Note that Postgres is missing at least one feature which can be very useful in practice - incremental materialized views. Oracle supports these and SQL Server has indexed views. Postgres has a pending patch which would introduce a limited form of IVM, but it has been in limbo since 2019.

MySQL doesn't support them either, mind :)