Giter VIP home page Giter VIP logo

elastic's People

Contributors

avitex avatar colonelthirtytwo avatar cristicbz avatar dtolnay avatar dylan-dpc avatar ilya-epifanov avatar incker avatar kodraus avatar mtorromeo avatar mwilliammyers avatar obarros avatar petrochenkov avatar shepmaster avatar stephanbuys avatar stephanh avatar tobias-o avatar tompridham avatar tshepang avatar waywardmonkeys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

elastic's Issues

Add elastic_types_codegen dylib crate

Move the parsing for Format into a compiler plugin crate so that we can provide a parse plugin to get Items at compile time, instead of parsing at runtime

Better Error Handling for macros Plugins

Rather than calling .unwrap(), which will panic on errors, tank the build and give an unhelpful error message, return span _err with a proper message, so users can see what's actually going on.

Commiting TODOs in Code

Use issues (like this one) instead of commiting todos in code. It's an unnecessary bit of commit history, but is just more convenient right now.

Cover all ES Date Formats

The date parser needs to provide the current implementation as a default for Format implementations, but also them to override it where the situation is unique, such as with epoch_millis where there's no equivalent chrono format.

  • Move parsing onto the Format trait
  • Provide a standard implementation
  • Overload where necessary
  • Ensure the date parser is complete and doesn't produce unexpected results (such as parsing just a . as milliseconds)

Multi Index Selection

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-index.html

On elastic_client, use an api like:

enum MultiIndexSelection {
    Include (&str),
    Exclude (&str)
}

enum IndexSelection {
    Single (&str),
    Multi (Vec <MultiIndexSelection>)
}

impl ToString for IndexSelection {
    fn to_string (&self) -> String {
        //Follow index formats for multi selection to return single string
    }
}

And take an Into <IndexSelection> in the elastic_client methods.

The &str in the selection may also need to be expanded.

Use Aster for Codegen

Currently, the codegen is mostly just rolled straight from the traits. It would be good to use aster rather than putting together giant ungainly syntax trees by hand.

Take an AstBuilder argument, so an ExtCtxt could be passed in too. A Span would also be a good thing to pass around, even though it will usually be a DUMMY_SP.

YAML Test Codegen

From #1 Some notes on the YAML format.

For do steps, if a body is supplied, expect it as JSON.

struct Do<'a> {
    name: &'a str,
    params: Vec<&'a str>
}

For match, is_false and is_true steps, parse to assert_eq, assuming there aren't any complex matches to deal with.

Use the free string on line 2 as either a comment on each test, or append to the test name.

There will need to be a coded response type, which should live in the types crate.

Tests for Rust Codegen

Test difficult codegen functions of #1 by generating and emitting a test source file, and verifying that it compiles.

It'd be cool if this could be wrapped up in a macro so it's run as a pre-compilation step

Improve Date Parse Performance

Currently, date formats are taken as strings and are parsed into tokens for then parsing again on the actual date.

While it's friendlier on the user to use string formats instead of collections of chrono Items, the performance improvement on not having to parse can't be ignored.

Time taken to parse a standard format:

test date::parse_date_format      ... bench:         275 ns/iter (+/- 19)

Time taken to parse a DateTime struct from &str format and Vec<Item> respectively.

test date::parse_date_from_format ... bench:         642 ns/iter (+/- 17)
test date::parse_date_from_tokens ... bench:         337 ns/iter (+/- 9)

It would be good to be able to offer either some kind of caching of parsed formats, or build a macro that parses formats at compile time.

Mod Path for Endpoints not Parsing

Need to write a test that uses the actual API spec source and gets mod paths, it doesn't seem to be correct for some reason on the actual data.

Fix Nightly Bugs

Changes in latest nightly for PatIdent are breaking the build

Helpers for genning fns from API AST

For #1

There need to be helpers in the codegen::api::gen::rust mod for taking an AST Endpoint and building functions from it.

This should also include meta for the module they should live in (eg cluster) and doc comments etc.

Json Repl API

Write some macros that take inline json and serialise it to JsonValue at compile time. For most cases, there would be 2 steps:

  1. Compile-time serialisation of json
  2. Runtime serialisation and replacement of replacement tokens

The macro design could look something like this:

json!(a, b, c, {
    'a': $a,
    'b': {
        'ba': $b
    },
    $c: 'value'
});

Where a, b and c are Serialize. The json! macro could be backed by two macros; one which does the actual parsing and serialisation, and the other that splices in replacement values:

let json = json_ser!({
    'a': $a,
    'b': {
        'ba': $b
    },
    $c: 'value'
});

This would result in:

JsonPartialResult {
    json: JsonValue,
    replacements: BTreeMap<String, ReplacementPath>
}

impl JsonPartialResult {
    pub fn replace(&self, repls: BTreeMap<String, JsonValue>) -> JsonValue;
}

enum ReplacementPath {
    Key(String),
    Value(String)
}

The replacements value would look like:

"a": Value("a"),
"b": Value("b.ba"),
"c": Key("")

We then use a macro to splice the replacements in. This would be done at runtime:

let mut repls = BTreeMap::with_capacity(3);
repls.insert("a", a);
repls.insert("b", b);
repls.insert("c", c);

let result = json.replace(repls);

If the json macro doesn't contain replacement chars, then we just return the result, otherwise, we return the expression calling json.replace, so values can be spliced in at runtime.

Reduce Allocations in Codegen

There are lots of messy allocations in the Codegen which can be tidied up. This doesn't need to be a high priority because the codegen isn't expected to be run by end-users, but should still be looked at at some point.

Parameter Types in Rust Codegen

Use the types from elastic_types as implementations for function parameters where necessary.

There shouldn't be too many of these, otherwise they could be taken as strings. If we can avoid introducing another dependency then that would be good.

Document Build Process

Currently, none of this compiles on the latest nightly channel, or with the latest versions of packages. This will need to change, but for now, setting the versions correctly in the cargo.toml files and listing the latest supported nightly build as supported would be helpful.

Support for optional time in dates

The Chrono library has separate structures for Date and DateTime. This doesn't work with Elasticsearch's default strict_date_optional_time format.

Can be implemented as a second-chance parse if pull request in chrono is merged chronotope/chrono#54

Emit Trait for Codegen

The generated code needs to be emitted somewhere, to a Writer.

There should be a base emit trait that can be implemented to output the results as a string to the writer.

Better Use of Chrono

The current way chrono is used is clunky.

The easiest solution will probably be to re-export the crate, so users don't specifically need to extern crate chrono unless they're already using it elsewhere.

Also implement From <chrono::DateTime <_>> for elastic_types::DateTime.

Online Docs

From #7 Add CI to online docs (which don't exist yet) using Travis.

Proper Error Handling for Spec Parse

Add a proper ParseError struct to handle parsing the API or Test specs. Needs to cover such issues as parsing and reading without being too opinionated about the source of the Read (file, url etc)

Documentation for Types

Need to add Rust docs to the types, with links back to the original Elasticsearch docs too where possible.

Correct use of epoch_millis Format

The current implementation of epoch_millis expects that the last 3 digits are millis and the rest are the epoch seconds.

This is correct for 13 digit timestamps, but may not necessarily be for smaller ones.

It's difficult to find examples on how this should work, different formatters seem to use different behaviour for millis.

Another issue is whether or not the millis on dates before the epoch should go down from 1000, instead of up to 1000. So should a timestamp of -1 be 31/12/1969 23:59:59.999 or 31/12/1969 23:59:59.001?

Make all Tests Without Asserts Doc Examples

Any tests that don't have an assert in them should be turned into documentation samples instead.

It'll make them more accessible to users, and not clutter up the tests with blocks of code that aren't really 'tests' anyway.

Better Tests for Codegen

The tests for the codegen need to be tidied up.

This test should verify that there is no extra path info on the type. And there should be a corresponding test to show that there can be full path info.

Make sure the alternative body adding fns are tested properly.

Fix Emit API

Changes in Rust seem to have broken the RustEmitter.

Add an explicit lifetime requirement to the Emitter trait, which will probably mean PhantomData on the ContextFreeEmitter.

Add hyper to crates.io

From #8

With the crate design sorted, they need to be uploaded to crates.io. This will include:

  • elastic_codegen: 0.2
  • elastic_types: 0.2
  • elastic_hyper: 0.2

The version numbers don't necessarily need to be in sync, but while they're covered by a single milestone it makes sense.

Initial Backlog Planning

Need to get some thoughts down about the feature requirements for this project and sort into milestones.

Some of this work is already done, but more is needed

Use Better Traits for Default Emit Impls

At the moment, primitive types are manually implemented for the Emit trait, but they could all be covered with a single impl of ToString. This could be a bit of a sledgehammer though, because it may get in the way of people implementing Emit themselves.

Keep an eye on how the Emit API is used, and rework the default impls if necessary

Sort out crate design

Need to get the crate design sorted for the key functionality:

  • API parsing
  • Codegen
  • Low-level client
  • High-level client
  • Core types

Some could be combined into a single crate, but these should be on crates.io once functionality is at a useable state.

Proper Rust Plugin Support for Codegen

Rework the rust codegen to be properly combatible with compiler plugins and macros.

This means we need to pass an ExtCtxt around and use it for identing etc. That'll also make it possible to replace some of the homegrown AST building with quotes.

Docs for types_codegen

Need to add documentation to the elsatic_types_codegen crate. This should cover the parsing and the plugin marcos.

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.