{"id":13646072,"url":"https://github.com/blablacar/go-synapse","last_synced_at":"2025-04-21T17:31:59.418Z","repository":{"id":149248804,"uuid":"49746654","full_name":"blablacar/go-synapse","owner":"blablacar","description":"Service discovery router","archived":true,"fork":false,"pushed_at":"2019-08-23T12:07:19.000Z","size":916,"stargazers_count":25,"open_issues_count":11,"forks_count":8,"subscribers_count":51,"default_branch":"master","last_synced_at":"2024-11-09T19:41:21.483Z","etag":null,"topics":["haproxy","infra","owner-infra","router","service-discovery"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blablacar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-01-15T21:44:06.000Z","updated_at":"2024-07-13T21:08:22.000Z","dependencies_parsed_at":"2023-09-03T09:00:29.618Z","dependency_job_id":null,"html_url":"https://github.com/blablacar/go-synapse","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blablacar%2Fgo-synapse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blablacar%2Fgo-synapse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blablacar%2Fgo-synapse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blablacar%2Fgo-synapse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blablacar","download_url":"https://codeload.github.com/blablacar/go-synapse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250100581,"owners_count":21374970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haproxy","infra","owner-infra","router","service-discovery"],"created_at":"2024-08-02T01:02:47.876Z","updated_at":"2025-04-21T17:31:57.597Z","avatar_url":"https://github.com/blablacar.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/blablacar/go-synapse.png?branch=master)](https://travis-ci.org/blablacar/go-synapse)\n\n# Synapse\n\nSynapse is a Service discovery mechanism. It watch servers for services in a backend and report status in a router.\nThis simplify service communication with backends and allow auto discovery \u0026 hot reconfiguration of the communication.\nThis provide better services discovery and fault-tolerant communication between services\n\nAt BlaBlaCar, we use a synapse for each service node that want to communicate with another service and discover those backend nodes (\u003e 2000). [Nerve](https://github.com/blablacar/go-nerve) report node statuses to a Zookeeper and synapse watch it to update a local Hapoxy. All outgoing communication is going through this haproxy.\n\n## Airbnb\n\nGo-Synapse is a go rewrite of Airbnb's [Synapse](https://github.com/airbnb/synapse) with additional features.\n\n## Installation\n\nDownload the latest version on the [release page](https://github.com/blablacar/go-synapse/releases).\n\nCreate a configuration file base on the doc or [examples](https://github.com/blablacar/go-synapse/tree/master/examples).\n\nRun with `./synapse synapse-config.yml`\n\n### Building\n_`****`_\nJust clone the repository and run `./gomake`\n\n\n## Configuration\n\nIt's a YAML file. You can find examples [here](https://github.com/blablacar/go-synapse/tree/master/examples)\n\nVery minimal configuration file with only one service :\n```yaml\nrouters:\n  - type: console\n    eventsBufferDurationInMilli: 500\n    services:\n      - serverSort: random          # random, name, date\n        watcher:\n          type: zookeeper\n          hosts: ['localhost:2181']\n          path: /services/api/myapi\n        serverOptions:              \n          ...                       # depend on router type\n        routerOptions:              \n          ...                       # depend on router type\n```\n\nRoot attributes:\n\n```yaml\nlogLevel: info\napiHost: 127.0.0.1\napiPort: 3454\nrouters:\n    ...\n```\n\n### Router config\n\n#### Router console\n\nNothing special to configure for this router.\n\n```yaml\n...\nrouters:\n  - type: console\n    services:\n      - ...\n```\n\n#### Router haproxy\n\nRouter have haproxy specific attributes, but there is also services attributes \n\n```yaml\n...\nrouters:\n  - type: haproxy\n    configPath: /tmp/hap.config\n    reloadCommand: [./examples/haproxy_reload.sh]\n    reloadTimeoutInMilli: 1000\n    reloadMinIntervalInMilli: 500\n    global:                                               # []string\n      - stats   socket  /tmp/hap.socket level admin\n    defaults:                                             # []string\n    listen:                                               # map[string][]string\n      stats:\n         - mode http\n         - bind 127.0.0.1:1936\n         - stats enable\n\n    services:\n      - watcher:\n          ...\n        serverOptions: check inter 2s rise 3 fall 2\n        routerOptions:\n          frontend:\n            - mode tcp\n            - timeout client 31s\n            - bind 127.0.0.1:5679\n          backend:\n            - mode tcp\n            - timeout server 2m\n            - timeout connect 45s\n```\n\nserverOptions support minimal templating:\n\n```\nserverOptions: cookie {{sha1String .Name}} check inter 2s rise 3 fall 2\nserverOptions: cookie {{randString 10}} check inter 2s rise 3 fall 2\nserverOptions: cookie {{.Name}} check inter 2s rise 3 fall 2\n```\n\n### Router template\n\n```yaml\n...\nrouters:\n  - type: template\n    destinationFile: /tmp/notexists/templated\n    templateFile: ./examples/template.tmpl\n    postTemplateCommand: [/bin/bash, -c, \"echo 'ZZ' \u003e /tmp/DDDD\"]\n\n    services:\n      - watcher:\n          ...\n```\n\n\n## Services\n\n```yaml\nrouters:\n  - type: ...\n\n    services:\n      - name: db-read\n        watcher:\n           ...\n        serverCorrelation: # this will remove the first server declared in otherService from this service\n          type: excludeServer\n          otherServiceName: db-write\n          scope: first\n\n```\n\n## Watcher config\n\n### zookeeper watcher\n\n```yaml\n\nrouters:\n  - type: ...\n\n    services:\n        - watcher:\n            type: zookeeper\n            hosts: [ 'localhost:2181', 'localhost:2182' ]\n            path: /services/es/es_site_search\n            timeoutInMilli: 2000\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblablacar%2Fgo-synapse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblablacar%2Fgo-synapse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblablacar%2Fgo-synapse/lists"}