{"id":15162052,"url":"https://github.com/simia-tech/netx","last_synced_at":"2025-10-24T22:32:25.818Z","repository":{"id":57498099,"uuid":"71458825","full_name":"simia-tech/netx","owner":"simia-tech","description":"Semantic addressing extention for golang's net package","archived":false,"fork":false,"pushed_at":"2018-12-05T15:29:23.000Z","size":151,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-09-29T10:47:34.037Z","etag":null,"topics":["consul","dnssrv","golang","grpc","http","microservice","nats","networking-stack"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simia-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-20T12:03:08.000Z","updated_at":"2021-12-07T21:26:19.000Z","dependencies_parsed_at":"2022-08-28T15:10:42.839Z","dependency_job_id":null,"html_url":"https://github.com/simia-tech/netx","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simia-tech%2Fnetx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simia-tech%2Fnetx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simia-tech%2Fnetx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simia-tech%2Fnetx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simia-tech","download_url":"https://codeload.github.com/simia-tech/netx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219867520,"owners_count":16555889,"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":["consul","dnssrv","golang","grpc","http","microservice","nats","networking-stack"],"created_at":"2024-09-27T01:04:32.166Z","updated_at":"2025-10-24T22:32:20.535Z","avatar_url":"https://github.com/simia-tech.png","language":"Go","readme":"# netx - Semantic addressing extention for go's net package\n\n[![GoDoc](https://godoc.org/github.com/simia-tech/netx?status.svg)](https://godoc.org/github.com/simia-tech/netx) [![Build Status](https://travis-ci.org/simia-tech/netx.svg?branch=master)](https://travis-ci.org/simia-tech/netx)\n\nThis package provides an extention of go stdlib's net package. It provides extended `Listen` and `Dial` methods\nin order to enabled clients and servers for semantic addressing. The returned structs implement `net.Listener` and\n`net.Conn` and should seamlessly integrate with your existing application.\n\nFor transport/service organisation, [NATS](http://nats.io), [consul](https://consul.io) or DNSSRV can be used. An\nimplementation of quic is in development.\n\nThe following examples require a local [NATS](http://nats.io) node on port 4222.\n\n## TCP connection example\n\n```go\nimport (\n  \"fmt\"\n\n  \"github.com/simia-tech/netx\"\n  _ \"github.com/simia-tech/netx/network/nats\"\n)\n\nfunc main() {\n  listener, _ := netx.Listen(\"nats\", \"echo\", netx.Nodes(\"nats://localhost:4222\"))\n  go func() {\n    conn, _ := listener.Accept()\n    defer conn.Close()\n\n    buffer := make([]byte, 5)\n    conn.Read(buffer)\n    conn.Write(buffer)\n  }()\n\n  client, _ := netx.Dial(\"nats\", \"echo\", netx.Nodes(\"nats://localhost:4222\"))\n  defer client.Close()\n\n  fmt.Fprintf(client, \"hello\")\n\n  buffer := make([]byte, 5)\n  client.Read(buffer)\n\n  fmt.Println(string(buffer))\n  // Output: hello\n}\n```\n\n## HTTP connection example\n\n```go\nimport (\n  \"net/http\"\n  \"fmt\"\n  \"io/ioutil\"\n\n  \"github.com/simia-tech/netx\"\n  _ \"github.com/simia-tech/netx/network/nats\"\n)\n\nfunc main() {\n  listener, _ := netx.Listen(\"nats\", \"greeter\", netx.Nodes(\"nats://localhost:4222\"))\n\n  mux := \u0026http.ServeMux{}\n  mux.HandleFunc(\"/hello\", func(w http.ResponseWriter, r *http.Request) {\n    fmt.Fprintf(w, \"Hello\")\n  })\n\n  server := \u0026http.Server{Handler: mux}\n  go func() {\n    server.Serve(listener)\n  }()\n\n  client := \u0026http.Client{\n    Transport: netx.NewHTTPTransport(\"nats\", netx.Nodes(\"nats://localhost:4222\")),\n  }\n  response, _ := client.Get(\"http://greeter/hello\")\n  defer response.Body.Close()\n\n  body, _ := ioutil.ReadAll(response.Body)\n  fmt.Println(string(body))\n  // Output: Hello\n}\n```\n\n## GRPC connection example\n\n```go\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"time\"\n\n\t\"golang.org/x/net/context\"\n\t\"google.golang.org/grpc\"\n\n\t\"github.com/simia-tech/netx\"\n\t_ \"github.com/simia-tech/netx/network/nats\"\n)\n\ntype echoServer struct{}\n\nfunc (e *echoServer) Echo(ctx context.Context, request *EchoRequest) (*EchoResponse, error) {\n\treturn \u0026EchoResponse{Text: request.Text}, nil\n}\n\nfunc main() {\n\tlistener, _ := netx.Listen(\"nats\", \"echo\", netx.Nodes(\"nats://localhost:4222\"))\n\n\tserver := grpc.NewServer()\n\tRegisterEchoServiceServer(server, \u0026echoServer{})\n\n\tgo func() {\n\t\tserver.Serve(listener)\n\t}()\n\n\tconn, _ := grpc.Dial(\"echo\",\n\t\tgrpc.WithDialer(netx.NewGRPCDialer(\"nats\", netx.Nodes(\"nats://localhost:4222\"))),\n\t\tgrpc.WithInsecure())\n\n\tclient := NewEchoServiceClient(conn)\n\n\tctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n\tresponse, _ := client.Echo(ctx, \u0026EchoRequest{Text: \"Hello\"})\n\tcancel()\n\n\tfmt.Println(response.Text)\n\t// Output: Hello\n}\n```\n\n## More examples\n\nMore example can be found in the [example](https://github.com/simia-tech/netx/tree/master/example) directory.\n\n## Tests\n\nIn order to run the tests, type\n\n    go test -v ./...\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimia-tech%2Fnetx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimia-tech%2Fnetx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimia-tech%2Fnetx/lists"}