Documentation ¶
Index ¶
- Variables
- func Marshal(t Marshaler) ([]byte, error)
- func Unmarshal(b []byte, t Unmarshaler) error
- type AppendRequest
- type ConnectionString
- type CreateTopicRequest
- type ErrResponse
- type ListRequest
- type ListResponse
- type Marshaler
- type Message
- type OkResponse
- type Printable
- type QueryRequest
- type QueryResponse
- type Request
- type ResponseWriter
- type StatsRequest
- type StatsResponse
- type Unmarshaler
- type UseRequest
- type VersionRequest
- type VersionResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // CommandVersion sends the version of the fossil protocol supported to the server / client CommandVersion = "VERSION" // CommandList sets the current database context CommandList = "LIST" // CommandUse sets the current database context CommandUse = "USE" // CommandError sends an error code and a message to the client CommandError = "ERR" // CommandOk is used to respond to generic actions CommandOk = "OK" // CommandStats retrieves the current database stats CommandStats = "STATS" // CommandQuery executes a query on the current database CommandQuery = "QUERY" // CommandAppend appends data to the current database CommandAppend = "APPEND" // CommandCreate is used to create topics (but could be used for other purposes in the future) CommandCreate = "CREATE" )
View Source
var ( Version = "v1.0.0" MessageOk = NewMessageWithType(CommandOk, OkResponse{Code: 200, Message: "Ok"}) MessageOkDatabaseChanged = NewMessageWithType(CommandOk, OkResponse{Code: 201, Message: "database changed"}) MessageError = NewMessageWithType(CommandError, ErrResponse{Code: 500}) MessageErrorCommandNotFound = NewMessageWithType(CommandError, ErrResponse{Code: 501, Err: fmt.Errorf("command not found")}) MessageErrorMalformedMessage = NewMessageWithType(CommandError, ErrResponse{Code: 502, Err: fmt.Errorf("malformed message")}) MessageErrorUnmarshaling = NewMessageWithType(CommandError, ErrResponse{Code: 506, Err: fmt.Errorf("error unmarshaling")}) MessageErrorUnknownDb = NewMessageWithType(CommandList, ListRequest{}) MessageList = NewMessageWithType(CommandError, ErrResponse{Code: 505}) )
View Source
var Protocol = "fossil"
Functions ¶
func Unmarshal ¶
func Unmarshal(b []byte, t Unmarshaler) error
Types ¶
type AppendRequest ¶
type ConnectionString ¶
func ParseConnectionString ¶
func ParseConnectionString(connStr string) (ConnectionString, error)
ParseConnectionString takes a connection string and parses it into the parts the application needs to make a connection. This function will always parse, even horribly malformed connection strings. It will only return an error if the protocol is not "fossil" or "file"
Formats:
./path/to/local/db file://./path/to/local/db fossil://<host:port>[/<db_name>]
type CreateTopicRequest ¶ added in v0.2.0
func (CreateTopicRequest) Marshal ¶ added in v0.2.0
func (rq CreateTopicRequest) Marshal() ([]byte, error)
Marshal ...
func (*CreateTopicRequest) Unmarshal ¶ added in v0.2.0
func (rq *CreateTopicRequest) Unmarshal(b []byte) error
Unmarshal ...
type ErrResponse ¶
func (ErrResponse) Headers ¶ added in v0.2.0
func (v ErrResponse) Headers() []string
func (ErrResponse) Values ¶ added in v0.2.0
func (v ErrResponse) Values() [][]string
type ListRequest ¶
type ListRequest struct {
Object string
}
type ListResponse ¶
type ListResponse struct {
ObjectList []string `json:"results"`
}
func (ListResponse) Headers ¶ added in v0.2.0
func (v ListResponse) Headers() []string
func (ListResponse) Values ¶ added in v0.2.0
func (v ListResponse) Values() [][]string
type Message ¶
type Message interface { Marshal() ([]byte, error) Unmarshal(r io.Reader) error Command() string Data() []byte MarshalZerologObject(e *zerolog.Event) }
func NewMessage ¶
func NewMessageWithType ¶
type OkResponse ¶
func (OkResponse) Headers ¶ added in v0.2.0
func (v OkResponse) Headers() []string
func (OkResponse) Values ¶ added in v0.2.0
func (v OkResponse) Values() [][]string
type QueryRequest ¶
type QueryRequest struct {
Query string
}
type QueryResponse ¶
func (QueryResponse) Headers ¶ added in v0.2.0
func (v QueryResponse) Headers() []string
func (QueryResponse) Values ¶ added in v0.2.0
func (v QueryResponse) Values() [][]string
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶
NewRequest creates a new request from the line message and the current client state
type ResponseWriter ¶
func (ResponseWriter) WriteMessage ¶
func (rw ResponseWriter) WriteMessage(t Marshaler) (int, error)
type StatsRequest ¶
type StatsRequest struct {
Database string
}
type StatsResponse ¶
type StatsResponse struct { AllocHeap uint64 `json:"alloc_heap"` TotalMem uint64 `json:"total_mem"` Uptime time.Duration `json:"uptime"` Segments int `json:"segments"` Topics int `json:"topics"` }
func (StatsResponse) Headers ¶ added in v0.2.0
func (v StatsResponse) Headers() []string
func (StatsResponse) Values ¶ added in v0.2.0
func (v StatsResponse) Values() [][]string
type Unmarshaler ¶
type UseRequest ¶
type UseRequest struct {
DbName string
}
type VersionRequest ¶
type VersionRequest struct {
Version string
}
func (VersionRequest) Marshal ¶
func (v VersionRequest) Marshal() ([]byte, error)
Marshal a VersionRequest. We don't actually use the specified version, and instead rely on the Version variable above
type VersionResponse ¶
func (VersionResponse) Headers ¶ added in v0.2.0
func (v VersionResponse) Headers() []string
func (VersionResponse) Marshal ¶
func (v VersionResponse) Marshal() ([]byte, error)
Marshal a VersionResponse. As with VersionRequest, we override the version specified in the supplied VersionResponse.
func (*VersionResponse) Unmarshal ¶
func (v *VersionResponse) Unmarshal(b []byte) error
Unmarshal ...
func (VersionResponse) Values ¶ added in v0.2.0
func (v VersionResponse) Values() [][]string
Click to show internal directories.
Click to hide internal directories.