#1 2022-03-21 04:51:08

igors233
Member
Registered: 2012-09-10
Posts: 234

TSynDaemon and TSynDaemonSettings

TSynDaemon only accepts TSynDaemonSettings and it defines all properties as published which is not ideal because end user can change ServiceName and log details.
I belive it would be better if there's a parent/abstract class for TSynDaemonSettings which is used by TSynDaemon that defines properties but doesn't publish any, something like:

  TCustomSynDaemonSettings  = class(TSynJsonFileSettings)
  protected
    fServiceName: string;
    fServiceDisplayName: string;
    ...
  published
     // empty list, nothing is published by default
  end;

  // And then I can decide what goes to settings file and can be changed by end user, for example:
  TMyAppSettings = class(TCustomSynDaemonSettings)
  private
    FSomeSetting: string;
  published
    property SomeSetting: string read FSomeSetting write FSomeSetting;
    property LogRotateFileCount; // allow user to change log rotate details only
  end;

Also would be good if ServiceDescription function is defined as virtual so a custom service description could be provided if needed.

Last edited by igors233 (2022-03-21 05:05:28)

Offline

#2 2022-03-21 08:15:30

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,240
Website

Re: TSynDaemon and TSynDaemonSettings

Good idea.

Should be available by https://github.com/synopse/mORMot2/commit/bc25e58c
and https://github.com/synopse/mORMot2/commit/804f08b6

(my modification doesn't change the current behavior, but you can inherit from TSynDaemonAbstractSettings if you need to hide some fields)

Offline

#3 2022-03-21 12:49:48

igors233
Member
Registered: 2012-09-10
Posts: 234

Re: TSynDaemon and TSynDaemonSettings

Excellent, works ideally, thank you.

Offline

Board footer

Powered by FluxBB