{"id":21141302,"url":"https://github.com/influx6/octo","last_synced_at":"2026-05-18T22:05:51.585Z","repository":{"id":57599061,"uuid":"82605928","full_name":"influx6/octo","owner":"influx6","description":"Octo provides a base low-level network communication across multiple protocols in Go.","archived":false,"fork":false,"pushed_at":"2017-05-17T13:37:53.000Z","size":4917,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-21T07:07:59.843Z","etag":null,"topics":["distributed-tcp-messaging","go","go-octo","golang","low-level-network-library","message-library","messaging-layer","octo","tcp","udp","websocket"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/influx6.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":"2017-02-20T21:45:58.000Z","updated_at":"2017-03-31T18:38:43.000Z","dependencies_parsed_at":"2022-09-26T19:53:00.747Z","dependency_job_id":null,"html_url":"https://github.com/influx6/octo","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/influx6%2Focto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influx6%2Focto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influx6%2Focto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influx6%2Focto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/influx6","download_url":"https://codeload.github.com/influx6/octo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243581094,"owners_count":20314167,"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":["distributed-tcp-messaging","go","go-octo","golang","low-level-network-library","message-library","messaging-layer","octo","tcp","udp","websocket"],"created_at":"2024-11-20T07:26:45.067Z","updated_at":"2026-05-18T22:05:51.518Z","avatar_url":"https://github.com/influx6.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Octo\n====\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/influx6/octo)](https://goreportcard.com/report/github.com/influx6/octo)\n\nOcto is a library providing a baseline architecture which is specifically for the creation of a service which is able to communicate through several underline transport protocol without change in the underline core messages sent and the logic used.\n\nOcto is intended to provide a system where we can easily build a service capable of talking with others and vice-versa through any supported procotols (http, websocket, udp and tcp). These then allows us easily create higher level services, which can easily be talked to with by clients using any procotol supported by the server.\n\nInstall\n-------\n\n```bash\ngo get -u github.com/influx6/octo\n```\n\nProtocols\n---------\n\nOcto currently provides 4 implemented protocols with plans to expand the list as time goes on.\n\n-\tTCP *Server and Client Packages*\n-\tHTTP *Server and Client Packages*\n-\tUDP *Server and Client Packages*\n-\tWebsocket *Server and Client Packages*\n-\tQuic (Pending)\n\nClient Libraries\n----------------\n\nAll supported protocols have Go based client libraries which allows connecting to given services and handle any internal operation private to these procotols. Octo also supports connections with the Http and Websocket protocols from NodeJS and Webbrowser through the [OctoJS](./octojs) package which allows connecting on javascript runtimes.\n\nExample\n-------\n\nBelow is demonstrated a codebase which showcases usage of the http and websocket server protocols for use with the OctoJS client library.\n\n*Octo enforces no selective rules has to the contents of a message and it's format, although certain formats such as `json` are used underneath for internal logic between client and servers but users are free to create or use any message format needed and as decided on the server*\n\nThe sample uses a combination of JSON and text responses but users will easily be able to change this as suited.\n\n-\tClient Code(`index.html`\\)\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003ctitle\u003e\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003e Websocket test \u003c/h1\u003e\n    \u003cp\u003eOpen console in developer tools to see output\u003c/p\u003e\n    \u003cscript type=\"text/javascript\" src=\"assets/octojs.js\"\u003e\u003c/script\u003e\n    \u003cscript type=\"text/javascript\"\u003e\n    const octo = require(\"octojs\");\n    const auth = octo.AuthCredentials(\"XScheme\", \"Rack\", \"4343121-GU\", \"Teddybear\")\n\n    const httpAttr = octo.Attr(\"http://localhost:5060\", [], auth)\n    const socketAttr = octo.Attr(\"ws://localhost:6060\", [], auth)\n\n    console.log(\"HTTP:Attr: \", httpAttr)\n    console.log(\"Websocket:Attr: \", socketAttr)\n\n    const http = new octo.HTTPClient(httpAttr, function(data, tx, res){\n      var answers = data.toString().split(\"\\r\\n\").filter(function(item){\n        return item.length !== 0\n      })\n\n      console.log(\"HTTP:Answers: \", answers)\n    })\n\n    http.Do(octo.BufferMessage([\n      {\"name\": \"REX\", \"data\": null},\n      {\"name\": \"PUMP\", \"data\": null},\n    ]))\n\n    const socket = new octo.WebsocketClient(socketAttr, {\n      error: function(err){\n        console.log(\"Error: \", err)\n      },\n      data: function(data, tx, res){\n        var answers = data.toString().split(\"\\r\\n\").filter(function(item){\n          return item.length !== 0\n        })\n\n        console.log(\"Websocket:Answers: \", answers)\n      },\n    });\n\n    socket.Do(octo.BufferMessage([\n      {\"name\": \"REX\", \"data\": null},\n      {\"name\": \"PUMP\", \"data\": null},\n    ]));\n\n    \u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n\n```\n\n-\tServer Code\n\n```go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"fmt\"\n\t\"log\"\n\tclassicHttp \"net/http\"\n\t\"os\"\n\t\"os/signal\"\n\n\t\"github.com/influx6/octo\"\n\t\"github.com/influx6/octo/consts\"\n\t\"github.com/influx6/octo/instruments\"\n\t\"github.com/influx6/octo/messages/jsoni\"\n\t\"github.com/influx6/octo/mock\"\n\t\"github.com/influx6/octo/streams/server\"\n\t\"github.com/influx6/octo/streams/server/http\"\n\t\"github.com/influx6/octo/streams/server/websocket\"\n)\n\nvar (\n\tpocket = octo.AuthCredential{\n\t\tScheme: \"XScheme\",\n\t\tKey:    \"Rack\",\n\t\tToken:  \"4343121-GU\",\n\t\tData:   \"Teddybear\",\n\t}\n)\n\ntype mockSystem struct{}\n\n// Authenticate authenticates the provided credentials and implements\n// the octo.Authenticator interface.\nfunc (mockSystem) Authenticate(cred octo.AuthCredential) error {\n\tif cred.Scheme != pocket.Scheme {\n\t\treturn errors.New(\"Scheme does not match\")\n\t}\n\n\tif cred.Key != pocket.Key {\n\t\treturn errors.New(\"Key does not match\")\n\t}\n\n\tif cred.Token != pocket.Token {\n\t\treturn errors.New(\"Token does not match\")\n\t}\n\n\treturn nil\n}\n\n// Serve handles the processing of different requests coming from the outside.\nfunc (mockSystem) Serve(message []byte, tx server.Stream) error {\n\tfmt.Printf(\"Message: %+q\\n\", message)\n\n\tcmds, err := jsoni.Parser.Decode(message)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcommands, ok := cmds.([]jsoni.CommandMessage)\n\tif !ok {\n\t\treturn consts.ErrParseError\n\t}\n\t\n\t// We personally want this example to bundle the response together, but this is not standard (nor is there a standard)\n\t// It can equally respond to each individual command seperately.\n\tvar res bytes.Buffer\n\n\tfor _, command := range commands {\n\t\tswitch command.Name {\n\t\tcase \"PUMP\":\n\t\t\tres.WriteString(\"DUMP\\r\\n\")\n\t\t\tcontinue\n\t\tcase \"REX\":\n\t\t\tres.WriteString(\"DEX\\r\\n\")\n\t\tdefault:\n\t\t\treturn errors.New(\"Invalid Command\")\n\t\t}\n\t}\n\n\treturn tx.Send(res.Bytes(), true)\n}\n\nfunc main() {\n\tvar system mockSystem\n\n\tinstruments := instruments.Instruments(mock.NewLogger(), nil)\n\n\thttpServer := http.New(instruments, http.BasicAttr{\n\t\tAddr:         \"127.0.0.1:5060\",\n\t\tAuthenticate: true,\n\t\tAuth:         pocket,\n\t})\n\n\tsocketServer := websocket.New(instruments, websocket.SocketAttr{\n\t\tAuthenticate: true,\n\t\tAddr:         \"127.0.0.1:6060\",\n\t\tOriginValidator: func(r *classicHttp.Request) bool {\n\t\t\treturn true\n\t\t},\n\t})\n\n\tif err := httpServer.Listen(system); err != nil {\n\t\tlog.Fatalf(\"Failed to start http server: %+q\", err)\n\t}\n\n\tif err := socketServer.Listen(system); err != nil {\n\t\tlog.Fatalf(\"Failed to start http server: %+q\", err)\n\t}\n\n\tdefer socketServer.Close()\n\tdefer httpServer.Close()\n\n\tlog.Printf(\"HTTP Server started @ %+q\", httpServer.Attr.Addr)\n\tlog.Printf(\"Websocket Server started @ %+q\", socketServer.Attr.Addr)\n\n\t// Listen for an interrupt signal from the OS.\n\tsigChan := make(chan os.Signal, 1)\n\tsignal.Notify(sigChan, os.Interrupt)\n\t\u003c-sigChan\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finflux6%2Focto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finflux6%2Focto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finflux6%2Focto/lists"}