Coder Social home page Coder Social logo

synchronous publisher? about mulog HOT 2 CLOSED

brunobonacci avatar brunobonacci commented on September 4, 2024
synchronous publisher?

from mulog.

Comments (2)

BrunoBonacci avatar BrunoBonacci commented on September 4, 2024

Hi Peter,

regarding the synchronous publisher, it is a decision/constraint I've made early on and described in the internals.
For the intended use of this library, events are something useful but not essential, something that can be dropped/discarded as long as the handling of the events doesn't impact the "normal flow of the program".

A synchronous publisher would impact the performances of each event logged thus contradicting the design goals,
and in some case could also alter the flow which is definitely something i'm trying to avoid.
There are plenty of articles mentioning how logging can impact performances and stability.

I have a good experience building event-sourced systems and it is extremely difficult to build a general-purpose library to record events. There are fundamental decisions which need to be made case by case most of which boil down to where to you keep the events before acknowledgement and whether failing to store an event should fail the client acknowledgement as well.
These decisions will be different in different environments and for different type of events. Such decisions fit more the world of a framework rather than a library. Such frameworks will be built with different technologies for clouds and traditional environments.

Regarding the second part, the global logger, although µ/log has a default global logger, the fundamental core logging function log* takes a logger which is a dynamic binding which in the log macro defaults to core/*default-logger* and can be redefined with binding.

(binding [com.brunobonacci.mulog.core/*default-logger* (atom (rb/ring-buffer 1000))]
  (µ/log ::my-event :tag1 "val1"))

However, if your intent is to send a different set of events to different publishers, then the best way to achieve this is to use :transform configuration available in all built-in publishers.

Here an example

(μ/start-publisher!
 {:type :multi
  :publishers
  [{:type :console}
   {:type :simple-file :filename "/tmp/mulog/events1.log" 
    :transform #(filter (where :mulog/event-name :in? [:foo :bar]) %)}
   {:type :simple-file :filename "/tmp/mulog/events2.log"
    :transform #(filter (where :mulog/event-name :in? [:baz :bar]) %)}]})

(this example uses the where library to create predicate functions)

In the above example only the events :foo and :bar are sent to file "/tmp/mulog/events1.log",
and only the events :baz and :bar are sent to file "/tmp/mulog/events2.log",
finally all the events are published on the console.

from mulog.

xificurC avatar xificurC commented on September 4, 2024

Hi Bruno,

thank you for your quick response. I am aware of your choices and they make a lot of sense for logging. I was just thinking if this particular shoe wouldn't fit 2 different feet :) Your experience says no. Thank you.

from mulog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.