radio-t / stream-recorder

Резервная запись подкаста
MIT License
6 stars 2 forks source link

General observations about POC version #2

Open umputun opened 5 months ago

umputun commented 5 months ago

First of all, thank you for taking care of this project; I appreciate it.

After a quick review, I have prepared a list of potential improvements:

By and large, I'd like to see the project resembling other parts, e.g., super-bot, tg-spam, publisher, rss_generator. The reason for this is that a similar structure will make long-term maintenance easier for someone familiar with other parts of this infrastructure. For the same reason, I would like to simplify the structure and keep only what we really need without adding unnecessary abstractions and specialized tooling. I think the structure can be as simple as main.go and main_test.go (maybe with test data too) at the app level and a server package for everything else. Well, we can also have a recorder package if we really need it. Probably all we should have in the server package is a server.go handling all the routes and a recorder doing the recording, plus test files and mock files.

A couple of functional requirements I have not mentioned before:

umputun commented 5 months ago

cc @ar2rworld

umputun commented 5 months ago

Running shell-related things

It appears that syscall.Statfs func can replace the df call.

umputun commented 5 months ago

after #5 merge:

main.go

        wg.Add(1)
        go func() {
            defer wg.Done()
            s := server.NewServer(opts.Port, opts.Dir, revision)
            go s.Start()
        }()
    if revision == "local" {
        slog.SetLogLoggerLevel(slog.LevelDebug)
    }
umputun commented 5 months ago

package recorder:

I also don't get how the main-level ticker is supposed to work with the recorder. To me, it looks like it will create a new stream every 5 seconds, and you will end up with multiple recorders storing the stream into the common file. If this is the case, this is not right. If not, probably some comments are needed around the ticker, explaining the flow. If this is the error as I think it is, it would be a very clear reason why this app needs real integration tests. Such types of high-level logical issues are very well captured by such tests.

umputun commented 5 months ago

server: