Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for plugging in custom storage backends #250

Open
gstefanic opened this issue Jan 16, 2025 · 3 comments
Open

Add support for plugging in custom storage backends #250

gstefanic opened this issue Jan 16, 2025 · 3 comments

Comments

@gstefanic
Copy link

Galene currently reads JSON files from the disk to get group information and server configuration. Maybe define a nice API to implement so that a custom backed for storing and reading group information can be used.

@jech
Copy link
Owner

jech commented Jan 16, 2025

Could you please explain what you are trying to achieve? It's difficult to design an API without understanding concrete needs.

@gstefanic
Copy link
Author

I apologize for not providing enough details about the request.

Currently, JSON files on the disk are used as persistent storage for group information (eg. group name, allowed users, wildcard users, etc.). Instead of having this information in JSON files on the disk I would like to use SQL database as a persistent storage. Similar for data/config.json. For recordings something similar could be available, so that video is not written directly on the FS but rather that I get a callback to my function (for each encoded frame or something similar).

I've checked the code quite a bit, but I did not find such thing/api to be currently available in Galene, is this correct?

I managed to get a POC of this working, but not sure if it is general or it is only for my use case:
group/api.go

package group

type ApiI interface {
	DescriptionMatch(d1, d2 *Description) bool
	DescriptionUnchanged(name string, desc *Description) bool
	ReadDescription(name string, allowSubgroups bool) (*Description, error)
	GetConfiguration() (*Configuration, error)
}

type galeneImpl struct{}

var apiImpl ApiI = new(galeneImpl)

func Api() ApiI {
	return apiImpl
}

func SetExternalApiImpl(impl ApiI) {
	apiImpl = impl
}

And then for example in group/description.go:

// descriptionMatch returns true if the description hasn't changed between
// d1 and d2
func descriptionMatch(d1, d2 *Description) bool {
	return Api().DescriptionMatch(d1, d2)
}

func (g *galeneImpl) DescriptionMatch(d1 *Description, d2 *Description) bool {
	if d1.FileName != d2.FileName {
		return false
	}

	if d1.fileSize != d2.fileSize || !d1.modTime.Equal(d2.modTime) {
		return false
	}
	return true
}

I hope this better explains what I am trying to achieve. If not, I look forward to providing more information.

@jech
Copy link
Owner

jech commented Jan 16, 2025

I hope this better explains what I am trying to achieve.

It doesn't explain why you are doing this. What concrete problem are you trying to solve?

I'm guessing that you are deploying Galene in an interesting manner, and that you cannot reasonably provide a writable filesystem. I need to understand your deployment before I can start having an opinion on your solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants