You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @aswallz, could you elaborate how you want to use this package? Do you want to search for files from you code?
This program is not designed to be used from code. You could still do that by doing something similar as the file cmd/server/main.go:
fileChangeChan := make(chan fanotify.FileChange, 100)
requestChan := make(chan request.Request)
go fanotify.Listen(fileChangeChan) // listen to file changes on the system
go database.Start(fileChangeChan, requestChan) // start the database, this also creates an initial index of the whole file system
go request.ListenAndServe(requestChan) // set up a server that listens for requests.
you wouldn't set up the server (the last line). instead you can construct Requests yourself and send them through the requestChan channel and listen for the results on the ResponseChannel field of the Request which you constructed. You might want to write a wrapper for that.
Ideally though we would refactor this whole thing. database should be a struct of a databaser(?) interface which defines functions to report file changes, to query the database and to create the initial index (maybe the latter should be somewhere else). Then you would be able to simply create a database struct and call functions on it to query. Then the whole channel stuff would build on top of that, so we we'd have a cleaner separation of concerns.
How can I import this project in my code? does it have documents and examples?
The text was updated successfully, but these errors were encountered: