Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple client to view records of tables via Txn #57

Closed
wants to merge 17 commits into from

Conversation

manhdaovan
Copy link

@manhdaovan manhdaovan commented Feb 18, 2019

As the issue here: #41
I want to add a simple client to view the records of tables in memdb.

The idea is I added a thing called Explorer, which can explore data of table with given table name, and a http server to display explored data.

  • To init an Explorer, you just need passing an instance of Txn struct to memdb.NewExplorer method. Then you can use any http server to display records with your own implement.

  • Or you can use explorer_server.NewServer to init built-in explorer server.
    (You need Gin as dependency, and given assets and templates paths to Gin as well)

  • Please ref to explorer_example/main.go for more details.

Here are some screenshots:

  • List all tables:
    screen shot 2019-02-18 at 17 30 25

  • List records of a table:

    • In html format:
      screen shot 2019-02-18 at 14 52 32

    • In json format:
      screen shot 2019-02-18 at 14 52 45

@hashicorp-cla
Copy link

hashicorp-cla commented Feb 18, 2019

CLA assistant check
All committers have signed the CLA.


import (
"github.com/gin-gonic/gin"
"github.com/manhdaovan/go-memdb"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: need changing to "github.com/hashicorp/go-memdb" after merged.

package main

import (
"github.com/manhdaovan/go-memdb"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: need changing to "github.com/hashicorp/go-memdb" after merged.

@salaxander
Copy link

@manhdaovan @armon @dadgar et all - Any chance of revisiting this? It would be a hugely helpful feature for a project I'm working on :)

@dnephin
Copy link
Contributor

dnephin commented Apr 29, 2021

Thank you @manhdaovan for all of your work on this! And thank you @salaxander for your interest!

I think this is a really cool idea. Being able to explore the tables and indexes in a memdb would be a really useful.

Unfortunately I don't think this is something we can maintain as part of go-memdb. It significantly expands the scope of this repo, and introduces new dependencies and technologies that we don't already use.

I'd like to propose the following as a path forward:

  1. Create a new repo for this UI client and add the code to the new repo
  2. Figure out what additional methods we need to export in memdb to make this UI possible from an separate package
  3. Add a link to the new repo from the go-memdb readme or docs, so that others can find this tool

I'm happy to help with 2 and 3. I believe currently explorer.go needs to access internals, but I wonder if we could take another approach. Could we pass in the full memdb.DBSchema to the explorer? Would that provide a lot of the data that explorer needs? It is possible to call Txn.Get(table, "id") (with no additional arguments) and get back all the entries in the table. I think would allow the explorer to do the necessary pagination. I only took a quick look, so maybe I have missed anything.

@salaxander
Copy link

@dnephin Sounds like a good path forward! I'm happy to help out in whatever capacity is needed :)

@manhdaovan
Copy link
Author

manhdaovan commented Dec 15, 2023

Oh, I didnt have a look to this PR for a long time

@dnephin
You are correct. Explorer needs to access to some internal stuff to get the data, so 2 is the best choice I think.

@salaxander
The no 2 is already implemented here, then we can easily to access to schema from outside. So maybe you can get started to build an UI for it.

Btw, as no 2 is already implemented, then this PR is unnecessary anymore.

@manhdaovan manhdaovan closed this Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants