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

Consider making sources independent of sourceiface.Source #167

Open
adatzer opened this issue Jul 5, 2022 · 1 comment
Open

Consider making sources independent of sourceiface.Source #167

adatzer opened this issue Jul 5, 2022 · 1 comment

Comments

@adatzer
Copy link
Contributor

adatzer commented Jul 5, 2022

Currently the return values of functions that create a new source (in each source package) are (sourceiface.Source, error).
Example: stdin source, etc.

However this is not necessary, since each source implements the Source interface, but does not use it. In addition, in GetSource we also check whether the component returned does indeed implement the Source interface.
Instead we could potentially make those functions return each specific source type (like what targets do).
For example:

// before
func configFunction(c *configuration) (sourceiface.Source, error)

// after (e.g. for kinesis source)
func configFunction(c *configuration) (*kinesisSource, error)

This would also allow us to mock a specific source more easily for the cases where the Source interface functionality is not needed/tested (for example here).

Not sure if this is a good call, just found myself thinking about it a couple of times and thought to trigger a discussion.

@colmsnowplow
Copy link
Collaborator

colmsnowplow commented Aug 9, 2022

Yup this makes sense - there's no need for us to use the interface type here at all. Each source config function should just return its source. Good spot!

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