{"id":16265536,"url":"https://github.com/bruth/ntable","last_synced_at":"2025-04-08T14:36:05.199Z","repository":{"id":57610773,"uuid":"106686796","full_name":"bruth/ntable","owner":"bruth","description":"A table data structure for NATS Streaming.","archived":false,"fork":false,"pushed_at":"2017-10-12T12:20:17.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T10:56:02.860Z","etag":null,"topics":["key-value","nats","nats-streaming","table"],"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/bruth.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-10-12T11:59:03.000Z","updated_at":"2017-10-12T17:04:03.000Z","dependencies_parsed_at":"2022-09-26T20:01:08.522Z","dependency_job_id":null,"html_url":"https://github.com/bruth/ntable","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/bruth%2Fntable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruth%2Fntable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruth%2Fntable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruth%2Fntable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bruth","download_url":"https://codeload.github.com/bruth/ntable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247862008,"owners_count":21008606,"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":["key-value","nats","nats-streaming","table"],"created_at":"2024-10-10T17:09:36.220Z","updated_at":"2025-04-08T14:36:05.177Z","avatar_url":"https://github.com/bruth.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NTable\n\n[![License MIT](https://img.shields.io/badge/License-MIT-blue.svg)](http://opensource.org/licenses/MIT)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bruth/ntable)](https://goreportcard.com/report/github.com/bruth/ntable) [![Build Status](https://travis-ci.org/bruth/ntable.svg?branch=master)](http://travis-ci.org/bruth/ntable) [![GoDoc](https://godoc.org/github.com/bruth/ntable?status.svg)](http://godoc.org/github.com/bruth/ntable)\n\nA table data structure for NATS Streaming.\n\nThe primary use case for maintaining a lookup table of data derived from a stream. It does this by maintaining an internal key-value store. The default implementation uses an in-memory store, but stores are easy to implement since the interface is a basic key-value interface.\n\n```go\ntype Store interface {\n  Get(key []byte) ([]byte, error)\n  Set(key, val []byte) error\n  Del(key []byte) error\n}\n```\n\n## Status\n\nDesign phase. Suggestions welcome.\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/bruth/ntable\"\n\t\"github.com/nats-io/go-nats-streaming\"\n)\n\n// Record with an ID and some data.\ntype Record struct {\n\tID   string\n\tData string\n}\n\nfunc main() {\n\tconn, _ := stan.Connect(\"test-cluster\", \"test-client\")\n\n\tt := \u0026ntable.Table{\n\t\tConn:    conn,\n\t\tChannel: \"users\",\n\t\t// Takes a message, derives the key and value and updates the store.\n\t\tHandle: func(s ntable.Store, m *stan.Msg) {\n\t\t\tvar r Record\n\t\t\tjson.Unmarshal(m.Data, \u0026r)\n\t\t\ts.Set([]byte(r.ID), []byte(r.Data))\n\t\t},\n\t}\n\n\t// Open connection (subscription) to channel.\n\tt.Open()\n\tdefer t.Close()\n\n\t// Publish a record about \"pam\" (likely happening from another process or thread).\n\tb, _ := json.Marshal(\u0026Record{\n\t\tID:   \"pam\",\n\t\tData: \"color=blue city=Philadelphia food=sushi\",\n\t})\n\tconn.Publish(\"users\", b)\n\n\t// A few moments pass..\n\ttime.Sleep(5 * time.Millisecond)\n\n\t// We can get the data about pam using the table.\n\tval, _ := t.Get([]byte(\"pam\"))\n\n\tfmt.Println(string(val))\n}\n```\n\n## License\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruth%2Fntable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbruth%2Fntable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruth%2Fntable/lists"}