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

(#1092) add an external discovery method #1093

Merged
merged 1 commit into from Jan 18, 2021
Merged

Conversation

ripienaar
Copy link
Member

Signed-off-by: R.I.Pienaar rip@devco.net

require "json"
require "pp"

if ARGV.length != 1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just to test the arg parsing works, and probably not even a good test, wouldnt be needed normally

@ripienaar
Copy link
Member Author

Using this with the go-external helper making a new discovery method is basically:

func main() {
	jsonDiscovery := discovery.NewDiscovery(func(ctx context.Context, timeout time.Duration, collective string, filter discovery.Filter) ([]string, error) {
		f, _ := ioutil.ReadFile("/etc/choria/nodes.json")
		nodes := []string{}
		err := json.Unmarshal(f, &nodes)
		
		return nodes, err
	})
	
	jsonDiscovery.ProcessRequest()
}

Signed-off-by: R.I.Pienaar <rip@devco.net>
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

Successfully merging this pull request may close these issues.

None yet

1 participant