{"id":21995221,"url":"https://github.com/aravinth2094/nio","last_synced_at":"2025-03-23T04:17:36.493Z","repository":{"id":57593830,"uuid":"373914937","full_name":"aravinth2094/nio","owner":"aravinth2094","description":"Golang NIO Client","archived":false,"fork":false,"pushed_at":"2021-06-04T18:03:27.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-28T10:44:38.206Z","etag":null,"topics":["asynchronous","client","client-server","golang","nio","socket"],"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/aravinth2094.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":"2021-06-04T17:26:29.000Z","updated_at":"2021-06-22T07:06:54.000Z","dependencies_parsed_at":"2022-09-26T19:43:50.426Z","dependency_job_id":null,"html_url":"https://github.com/aravinth2094/nio","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravinth2094%2Fnio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravinth2094%2Fnio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravinth2094%2Fnio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravinth2094%2Fnio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aravinth2094","download_url":"https://codeload.github.com/aravinth2094/nio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245052662,"owners_count":20553172,"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":["asynchronous","client","client-server","golang","nio","socket"],"created_at":"2024-11-29T21:13:19.522Z","updated_at":"2025-03-23T04:17:36.451Z","avatar_url":"https://github.com/aravinth2094.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Golang NIO Client\n\n* This is a Non-blocking IO socket client library that uses function callbacks to achieve asynchronous behaviour (javascript much?)\n* You can chain functions that you would like your data to pass through during read/write phase.\n\n\n```golang\npackage main\n\nimport (\n\t\"crypto/tls\"\n\t\"io\"\n\t\"log\"\n\t\"sync\"\n\n\tnio \"github.com/aravinth2094/nio\"\n)\n\nfunc main() {\n\n\tprintString := func(data []byte, err error) ([]byte, bool, error) {\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tlog.Fatalln(err)\n\t\t\t}\n\t\t\treturn nil, false, err\n\t\t}\n\t\tlog.Println(string(data))\n\t\treturn data, false, nil\n\t}\n\n\tprintBytesWritten := func(bytesWritten int, err error) {\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tlog.Fatalln(err)\n\t\t\t} else {\n\t\t\t\tlog.Println(err)\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Println(bytesWritten, \"bytes written\")\n\t\t}\n\t}\n\n\twg := \u0026sync.WaitGroup{}\n\twg.Add(1)\n\tchannel, err := nio.GetChannel(\"tcp\", \"localhost\", 8080, \u0026tls.Config{\n\t\tInsecureSkipVerify: true,\n\t})\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\twrite := channel.GetWriter(nio.ConvertToUpperCase, printString)\n\tchannel.Read(wg, nio.ConvertToUpperCase, printString, func(data []byte, err error) ([]byte, bool, error) {\n\t\tif err != nil {\n\t\t\treturn data, false, err\n\t\t}\n\t\twrite(append([]byte(\"hello \"), data...), printBytesWritten)\n\t\treturn data, false, nil\n\t})\n\tchannel.Write([]byte(\"Hi\"), printBytesWritten)\n\twg.Wait()\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faravinth2094%2Fnio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faravinth2094%2Fnio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faravinth2094%2Fnio/lists"}