fabric

package
v0.0.0-...-7112f6d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2021 License: GPL-2.0 Imports: 12 Imported by: 0

README

Fabric

This subpkg generates structs used to decode the formats of a git.Commit to a native go struct (friendlier that managing commit changes and better than using unsafe maps).

Notice that every generation needs a valid schema to be performed.

An alternative to this could be using gojson, creating the templates for every endpoint manually.

Getting started

The standard usage of this module would be:

  1. Fabric the structs with rtc fabric <SCHEMA_PATH>.
  2. Marshal the git.Commit using any utility provided in the msh pkg or use the Mapable provided abstraction to create your own marshaler.
  3. Unmarshal the obtained map to the struct you generated in the first step.

Example:

Using the github literal, first we are going to create the native structs for this rtc fabric literals/github.yaml.

Then, and after committing a few changes (see how to commit)[] we orchestrate the changes:

// Notice it avoids err checking <is an example>

import (
    "encoding/json"
    "context"

    fabric "my_fabric_dir/github"
    "github.com/sebach1/rtc/git"
    "github.com/sebach1/rtc/literals"
    "github.com/sebach1/rtc/literals/github"
    "github.com/sebach1/rtc/msh"
)

myOwner := git.NewOwner(literals.StdPlanisphere)

myOwner.Orchestrate(context.Background(), github.Community, "github", YOUR_COMMIT, git.AreCompatible())
myOwner.Close()

for _, result := range myOwner.Summary {
    comm := git.CommitById(ctx, db, result.CommitId)// find the created commit with your DB implementation
    jsComm, _ := msh.ToJSON(comm)
    repo := &fabric.Repository{}
    json.Unmarshal(jsComm, repo) // In case u are using json decoder
}

Documentation

Overview

Package fabric provides an easy way to create native struct receiver types given a schema

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fabric

type Fabric struct {
	Schema *schema.Schema
	Dir    string
	// contains filtered or unexported fields
}

Fabric creates native go struct types given a schema

func (*Fabric) Produce

func (f *Fabric) Produce(marshal string, fs afero.Fs) error

Produce is the main Fabric wrapper

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL