{"id":21964552,"url":"https://github.com/intob/chamux","last_synced_at":"2025-03-22T21:22:12.286Z","repository":{"id":144345763,"uuid":"462894580","full_name":"intob/chamux","owner":"intob","description":"net.Conn muxer for Go, based on channels","archived":false,"fork":false,"pushed_at":"2022-02-24T21:47:37.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T08:04:09.209Z","etag":null,"topics":["channels","concurrency","connection","multiplexer","mux","network","tcp"],"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/intob.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}},"created_at":"2022-02-23T20:26:11.000Z","updated_at":"2022-02-23T20:41:30.000Z","dependencies_parsed_at":"2023-07-17T20:40:09.361Z","dependency_job_id":"e1daa118-0638-438d-8e1f-b8019ab4334d","html_url":"https://github.com/intob/chamux","commit_stats":null,"previous_names":["dr-useless/chamux"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intob%2Fchamux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intob%2Fchamux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intob%2Fchamux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intob%2Fchamux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intob","download_url":"https://codeload.github.com/intob/chamux/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245021301,"owners_count":20548318,"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":["channels","concurrency","connection","multiplexer","mux","network","tcp"],"created_at":"2024-11-29T12:24:42.028Z","updated_at":"2025-03-22T21:22:12.243Z","avatar_url":"https://github.com/intob.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chamux\nA simple net.Conn multiplexer based on named topics \u0026 channels. Subscribing to a topic returns a channel on which updates will be sent.\n\n## Usage\n```go\nfunc dialer() {\n  // ignore the errors for brevity (it's an example)\n  conn, _ := net.Dial(\"unix\", \"/tmp/example\")\n\n  // implement chamux.Serializer to use another\n  mc := chamux.NewMConn(conn, chamux.Gob{}, chamux.Options{})\n\n  // get a channel for a topic named: coffee\n  topic := chamux.NewTopic(\"coffee\")\n  subscription := topic.Subscribe()\n  mc.AddTopic(\u0026topic)\n\n  sigint := make(chan os.Signal, 1)\n  signal.Notify(sigint, os.Interrupt)\n\nloop:\n  for {\n    select {\n    case \u003c-sigint:\n      mc.Close()\n      break loop\n    case msg := \u003c-subscription:\n      log.Println(\"something about coffee:\", string(msg))\n  }\n}\n\nfunc listener() {\n  listener, _ := net.Listen(\"unix\", \"/tmp/example\")\n  for {\n    conn, _ := listener.Accept()\n    mc := chamux.NewMConn(conn, chamux.Gob{}, chamux.Options{})\n\n    // send lots of messages about coffee\n    go func(chamux.MConn) {\n      for {\n        msg := []byte(\"we need more coffee\")\n        frame := chamux.NewFrame(msg, \"coffee\")\n        mc.Publish(frame)\n      }\n    }(mc)\n  }\n}\n```\n\n## Serialization\nThis package exports `Gob{}`. If you want to use another encoding, simply implement `Serializer`.\n```go\ntype Serializer interface {\n  Serialize(f *Frame) ([]byte, error)\n  Deserialize(f []byte) (*Frame, error)\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintob%2Fchamux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintob%2Fchamux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintob%2Fchamux/lists"}