Categorygithub.com/coopgo/forms
modulepackage
0.0.0-20210812141257-939da3a729fb
Repository: https://github.com/coopgo/forms.git
Documentation: pkg.go.dev

# README

coopgo/forms

made-with-Go GitHub go.mod Go version of a Go module go.dev reference

coopgo/forms is a web service written in Golang to handle forms data using différent data formats, protocols and backends

Communication protocols (transports) :

  • HTTP API (REST)
  • gRPC

Multiple transports can be run at the same time.

Different data backends / storages can be set :

  • Memory (temporary storage, for development/testing purpose)
  • PostgreSQL database (might also work with CockroachDB but not tested yet as we use the pgx driver compatible with both PostgreSQL and CockroachDB). PostgreSQL backend relies heavily on database tables/schemas generated on the fly (each table stores data from one form, even for unstructured forms, without defined schemas), so that we can easily plug another tool to visualize data like Apache Superset, Metabase or NocoDB.
  • Kantree (one way) (TODO : add some documentation about this)
  • Email with SMTP (one way)
  • Webhooks (one way)

"One way" backends do not store the form states. They could be better considered as "connectors" to other services, but are designed as the other backends in the code (they implement the same interface Backend).

At least one storage has to be set at the service level globally. These global storages cannot be "one way". Supported "global" storages are at the moment : Memory (temporary storage : only for development) and PostgreSQL

Multiple additional storages can be set for each form individually.

Our priority is to support memory (for easy development purpose), PostgreSQL, Kantree and Email (because that's our internal needs at COOPGO), but feel free to contribute something else (other databases, connectors to other services like chat apps, webhooks, etc...) if you want it first.

We have different types of forms :

  • Structured forms : forms with a defined schema. Every response must match the given schema. Structured forms schemas are defined using the JSON Type Definition standard.
  • Unstructured forms : forms accepting any input

Project Status

This project is still in development. It should be kind of functional using the PostgreSQL backend for simple use cases. Efforts still need to be made to support more complex forms with PostgreSQL and to implement other backends.

gRPC implementation and development considerations

This project uses protoc and protoc-gen-go-grpc to handle gRPC transport. You need to install and run them to build the project of changing anything on the gRPC side.

See https://grpc.io/docs/languages/go/quickstart/ for more details on how it works.

If you already know basics on this and have everything installed correctly, here is the command line to generate GRPC/Protocol buffers code inside the grpc package :

$ protoc -I grpc/ grpc/*.proto --go-grpc_out=./ --go_out=./

Contributing

We welcome any contributions following theses guidelines :

  • Any change to the code of the library must not break any transport or backend. Any new feature should be implemented for all if applicable.
  • Write simple, clear and maintainable code and avoid technical debt.
  • Leave the code cleaner than when you started.
  • Refactoring existing code for better performance, better readability or better testing wins over creating a new feature.

If you want to contribute, you can fork the repository and create a pull request.

Bug report

For reporting a bug, you can open an issue using the Bug Report template. Try to write a bug report that is easy to understand and explain how to reproduce the bug. Do not duplicate an existing issue and keep each issue specific to an individual bug.

License

coopgo/forms is under the Apache 2.0 license. Please refer to the LICENSE file for details.

# Packages

No description provided by the author

# Functions

No description provided by the author
NewRESTTransport creates a new transport using the REST protocol.
NewKantreeBackend initializes a new empty KantreeBackend.
NewPgsqlBackend initializes a new empty PgsqlBackend.
NewRESTTransport creates a new transport using the REST protocol.
NewService creates a new service with transports and backends.
NewStructuredForm creates a new structured form with a given ID and schema.
NewTempBackend initializes a new empty TempBackend.
NewUnstructuredForm creates a new unstructured form with a given id.
RESTBackend transforms a Backend to the RESTBackendDefinition type for correct JSON marshalling.
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
KantreeBackend is a backend using Kantree.
NoBackend is a fake backend implementation.
NoTransport is a fake transport.
PgsqlBackend is a backend using PostgreSQL.
RESTBackendDefinition defines the storage type and backend configuration Configuration keys depend on the storage type.
RESTFormDefintion is the form form definition The type of the form is "Unstructured" if there is no specific schema, or structured.
RESTTransport is the structure for the HTTP REST transport.
Service is the web service for the forms handling.
StructuredForm is a Form with a defined schema.
TempBackend is an in-memory temporary backend primarily used for testing and development purposes.
UnstructuredForm is a form without any given schema.

# Interfaces

Backend is the interface for backends (storage, data handling).
Form is the generic interface for forms.
No description provided by the author
Transport is the transport interface for communication with the outside world.

# Type aliases

DataType is the type to describe the forms data types (Text, Email, Boolean, Number, Location, ...).