Giter VIP home page Giter VIP logo

pkg's Introduction

Pkg

Pkg is a collection of Go libraries used in projects at ETHER labs.

It also contains useful packages for building go-kit based microservices along with interfaces for pubsub primitives.

Prior Art

License

Unless otherwise noted, the Pkg source files are distributed under the Apache Version 2.0 license found in the LICENSE file.

FOSSA Status

pkg's People

Contributors

dependabot-preview[bot] avatar karthikmuralidharan avatar mithunbelur avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

fossabot

pkg's Issues

Add a more backwards compliant errors package

Errors Proposal

Goals

  • To incorporate error codes in the new errors package. (Kind type defined below)
  • Build on top of pre-existing widely used errors package github.com/pkg/errors to minimise breaking changes.
  • Add a type called op based on Rob Pike’s package to hint the source of the error (under which function instead of using stack traces)
  • Incorporate utility functions to unwrap to the source of the kind of error to have alternative decision making.
  • Add support for marshalling and unmarshalling JSON request/responses.
  • Add support for error monadic types.

Prior Art

https://github.com/upspin/upspin/blob/master/errors/errors.go (Author Rob Pike and B Fitzgerald)
https://commandcenter.blogspot.com/2017/12/error-handling-in-upspin.html

https://github.com/pkg/errors/blob/master/errors.go (Dave Cheney, probably one of the most widely used error packages but does not support structured and over the wire marshal and unmarshal of JSON types)

Prior Effort

https://github.com/etherlabsio/pkg/tree/master/errors

  • Tried to fit all cases with a since error struct unlike github.com/pkg/errors which used composition of multiple struct types.
  • Re-implementing a lot of what was already implemented in the packages mentioned above.

errors.WithStack(err) error
errors.WithMessage(err, string)
errors.WithMessagef(err, string, interface{}…)
errors.Wrap(err, string)
errors.Wrapf(err, string, interface{}…)
errors.WithOp(err, op)
errors.WithOpf(err, op, “”, interface{}…)
errors.WithKind(err, kind)
errors.WithKindf(err, kind, string, interface{}…)
errors.New(interface{}…)

Other Essential functions for unwrapping the errors:

errors.Cause(err) error : Returns an error at root, I.e Cause of the original error
errors.IsKind(err) bool : Tells whether an error is of a specific kind (If you wrap multiple errors)
Errors.IsMatch(err1, err2) bool : Are these two errors of the same kind, or are they the exact same pointer reference?

Kind int

Shared Enums

    Internal // Internal error or inconsistency. This is the default if not provided.
    Invalid // Invalid operation for this type of item.
    Permission // Permission denied.
    IO // External I/O error such as network failure.
    AlreadyExist // Item already exists.
    NotExist // Item does not exist.

// Generally the function name you want to wrap the op as
Op string

type jsonError {
	Code int
	Op string (optional)
	Message string (optional)
}
// Error type  returned as part of errors.New
type Error struct {
	Kind Kind
	Op Op
	Cause error
}

Dependabot wasn't able to update github.com/nats-io/go-nats

The module path github.com/nats-io/go-nats found in your /go.mod doesn't match the actual path github.com/nats-io/nats.go found in the dependency's go.mod.

Updating the module path in your go.mod to github.com/nats-io/nats.go should resolve this issue.

You can mention @dependabot in the comments below to contact the Dependabot team.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.